But he was more than a match for 113th-ranked Krajinovic, breaking him early in each set and saving the only break point he faced.
Nadal, who lifted the Indian Wells trophy in 2007, 2008 and 2013, is in the last eight for the first time in three years after missing last year’s edition, skipping both Indian Wells and the Miami Masters with a hip injury.
He next will take on 13th-ranked Russian Karen Khachanov, who beat world number nine John Isner 6-4, 7-6 (7/1).
Khachanov produced just one ace to the big-serving American’s 12 but stretched his record over Isner to 4-0.
Fourth-seeded Federer, fresh off his 100th career title, looked poised to finish off Edmund in less than an hour.
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 was nervous, it’s OK to admit,” he said. “I was holding serve quite comfortably all day, Kyle came out and played a great last game.”
Federer will fight for a semi-final berth against 22-year-old Pole Hubert Hurkacz.
Hurkacz, ranked 67th in the world, sent 25th-ranked Canadian Denis Shapovalov packing 7-6 (7/3), 2-6, 6-3.
A day after world number one Novak Djokovic tumbled out of the third round, 19-year-old Miomir Kecmanovic kept the Serbian flag flying.
Kecmanovic became the first lucky loser to reach the last eight at Indian Wells since the ATP’s Masters 1000 series launched in 1990.
Kecmanovic, ranked 130th in the world, had taken the first set against Yoshihito Nishioka 6-4 when the 74th-ranked Japanese retired because of injury.
Kecmanovic, who gained entry to the second round when fifth-seeded Kevin Anderson withdrew with an elbow injury, is in his first ATP quarter-final.
“I’m really happy about it, especially since I didn’t really do anything before this,” said Kecmanovic, who will take on Canada’s 13th-seeded Milos Raonic in the quarters. “Obviously tough to see your opponent retire like that, but I’m still happy that I managed to get to the quarters.”
Kecmanovic is the last teen left in the men’s draw, after the departure of 19-year-old Shapovalov.
At the other end of the age spectrum, 40-year-old Croatian Ivo Karlovic took on 25-year-old seventh seed Dominic Thiem of Austria for a quarter-final berth.
The winner of that match will face either 18th-seeded Frenchman Gael Monfils or unseeded German Philipp Kohlschreiber — who stunned world number one Novak Djokovic 6-4, 6-4 on Tuesday.
Kohlschreiber, who had never beaten a top-ranked player in 11 prior attempts, will have to avoid a letdown against Monfils, who captured his eighth ATP title at Rotterdam last month.
It will be a tough task for Kohlschreiber, who has lost 13 of 15 prior meetings with Monfils.