Having lost seven games in a row, Krajinovic finally got on the board again with a hold for 3-1 in the second.
Meanwhile, Federer progressed to Round of 32 of the ongoing ATP Masters event in California. The 12-time Major victor was beaten in the fourth round of the Australian Open in January after his elbow troubles had kept him out of action since the 2017 Wimbledon Championships.
Though Djokovic came back to win the second set and celebrated with a once-trademarked roar, he went out with his latest whimper, losing 7-6 (3), 4-6, 6-1.
Federer, who had looked slightly off his game in his rain-disrupted third round match against Federico Delbonis, was his dominant self Monday, winning 89 per cent of his first service points while cracking six aces to just one double fault.
He is making a cautious return after an right elbow injury in 2017.
Nadal isn't playing at Indian Wells or the Miami Open after aggravating the leg injury that forced him out of the Australian Open in January.
The 12-time Grand Slam champion was far from his best tennis.
Other seeded players who lost were ninth-seeded Lucas Pouille, who fell 6-4, 6-4 to Yuki Bhambri; 14th-seeded Diego Schwartzman, 7-5, 6-4 to Marcos Baghdatis; 21st-seeded Kyle Edmund, 6-4, 6-4 to Dudi Sela; and number 24 seed Giles Muller, 6-3, 7-5 to Pierre-Hugues Herbert.
Marin Cilic is also through after a straight sets win over Marton Fucsovics 7-5 6-3 and Milos Raonic beat fellow Canadian Felix Auger-Aliassime 6-4 6-4.
In three tournaments prior to the Indian Wells Masters, he has reached the semi-finals only once.
He will face 25th-seed Filip Krajinovic in the third round.
On Saturday, Federer led 6-3, 2-2 when the match was delayed by a heavy drizzle 56 minutes after it began.
With two titles at St Petersburg and Doha and a 14-match winning streak, World No. 9 Petra Kvitova was one of the biggest contenders for the women's title.