The world number one would probably have beaten most players, even with the errors piling up and his serve out of sync, but not Swiss great Federer who sealed a semi-final spot with a match to spare.
Federer has now been responsible for three of Djokovic’s six defeats this season, edging ahead 22-21 in their career rivalry.
Djokovic’s first indoor loss since 2012, in which time he has won three consecutive London year-enders, means he needs to beat Czech Tomas Berdych on Thursday to be sure of joining Federer in the semi-finals.
Japan’s Kei Nishikori beat Berdych 7-5 3-6 6-3 in the day’s early offering, the first three-set match so far.
While it earned world number eight Nishikori another $167,000, the reward for a group win, it is likely to prove in vain unless he beats Federer in his final match and Berdych defeats Djokovic.
Djokovic could even scramble through with a three-set defeat, providing Nishikori does not win.
“These kind of things happen. I have to accept it and hopefully work on it tomorrow and get better in the next one,” Djokovic, winner of three of the year’s grand slams and a record six Masters Series titles, told reporters.
“Credit to Roger for mixing up the pace … I made a lot of unforced errors and just handed him the win in the second set,” added the 28-year-old who managed to win only a quarter of points on his first serve in the second set.
Djokovic had been untroubled until the 12th game when Federer earned a couple of set points, converting the second with a sublime half-volley dink off a dipping Djokovic backhand.
A tired-looking Djokovic backhand slice into the net gave Federer a 2-0 lead in the second set, and although the Swiss six-times champion gifted back the break, he raced away to a 5-2 lead and claimed victory on his second match point.
“I had focussed more on beating Berdych and Nishikori and let’s see what happens against Novak,” 34-year-old Federer told reporters. “That shows me that I didn’t expect this victory.”
Reacting to Djokovic’s claim that he handed him the win, Federer said: “It’s not like he played terrible. I know he can play better. Why did he play that way? I’d like to give myself credit for that, quite honestly, yeah.”
Nishikori and Berdych provided the match of the tournament so far — an absorbing duel full of eye-catching rallies.
World number eight Nishikori was in trouble when he faced a break point at 3-3 in the deciding set but he weathered a barrage of Berdych power to fend it off before going on to claim his first win in Stan Smith Group.
“That was a really big point. He had three, four shots that he went really aggressive. I was defending all the time. I mean, last shot, I kind of went for it, closed my eyes.”
“Was a little bit lucky I made that shot.”
World number six Berdych, beaten by Federer in his opening match, squandered a great chance in the first set when Nishikori was serving at 4-5 15-30, missing a wide-open court with a backhand at the end of a brilliant rally.
It proved costly as Berdych dropped serve in the next game and Nishikori clinched the set with a pinpoint forehand.
The 30-year-old Berdych reeled off five successive games on his way to win the second set and the decider was toe-to-toe, before the Czech flinched first.