Federer returned to stadium court on Sunday afternoon and needed an hour to close out his second-round victory 6-3, 7-6 (8/6).
Dimitrov, victor of the ATP World Tour Finals in 2017, lost the first set on a tie-break 7/4 but took the second 6-4 after breaking the 34-year-old on both of his first two service games.
Federer knows a thing or two about coming back from injury.
Federer and 10th seed Djokovic both came into the tournament seeking to become the first six-time victor of the event.
It was another snag in the return for the 30-year-old Djokovic who admitted he was out of sorts while playing in just his second event of 2018.
The 36-year-old had extra practice time this week after being given a bye in the first round at Indian Wells.
Federer, who defeated Federico Delbonis in the second round, will next face Jeremy Chardy after the world No 100 overcame countryman Adrian Mannarino, world No 23, 7-5 4-6 6-1.
"Getting through qualifying made me a bit more confident, which gave me the belief.to get through the tougher moments, even against someone like (Djokovic)", he said. "I'm glad I get the chance to play while she" still playing".
Indications that he was in good touch came in the second game of the match when he sealed a break to go 2-0 ahead.
In their only other ATP meeting in 2013, Delbonis won on clay in Hamburg 7-6 (9/7), 7-6 (7/4).
Daniel, meanwhile, will face the victor of the match between the Belgian Ruben Bemelmans and the Argentine Leonardo Mayer in the third round. There's not much to say about Federer that hasn't been said, as the guy has been a machine the last year or so, and he's not slowing down despite turning 37 years old later this summer. "I served well, and I think I played better than I expect before the match".
Twelve times grand slam champion Djokovic, who was seeded 10th, acknowledged his poor performance.
"I served well and played aggressive which was the key", Bhambri said.
In the evening session, seed Juan Martin del Potro dominates Australian teen De Minaur 6-2, 6-1.
Pablo Carreno Busta, the 11th seed, eventually overcame Daniil Medvedev on his fifth match point to secure a 6-1 7-5 win while world No 49 Borna Coric impressed with a 6-1 6-3 victory over 13th seed Roberto Bautista Agut.