The world number two will face Karen Khachanov in the quarters, after the Russian saw off John Isner of the United States, 6-4, 7-6 (1).
Fourth-seeded Federer, fresh off his 100th career title, looked poised to finish off Edmund in less than an hour.
Khachanov feels confident as he lost to Nadal just in four sets at the US Open: "I think it was one of the best matches from past year and in general, maybe, like, in terms of fight, spirit, intensity, the rallies, the atmosphere".
But the Swiss great had to fight off three break points as he served for the match before getting the job done on his first match point. "I hope I can get there, but I am not going to underestimate Hurkacz". Conditions are tough with the glare, and the jump of the ball is sometimes hard to find the rhythm and timing.
Speaking of their first meeting, Federer admitted the conditions of the match were tough but said Edmund still had what it takes to achieve big results.
Andreescu will get a shot at another top-10 player in the semi-finals, after sixth-ranked Elina Svitolina clawed out a 4-6, 6-4, 6-4 victory over another red-hot teen - Marketa Vondrousova of Czech Republic.
Kecmanovic became the first lucky loser to reach the last eight at Indian Wells since the ATP's Masters 1000 series launched in 1990.
In the women's draw one wildcard remains in the competition.
Awaiting Raonic in today's quarterfinals is 19-year-old Miomir Kecmanovic who earned a retirement from Yoshihito Nishioka.
"The previous days here in Indian Wells helped me a lot to get back to my top level physically and also to play good tennis again", Thiem said. I was able to mix up my game, cover my serve, be risky on the return.
Oddsmakers don't see much of a difference between the two veterans at the moment.