The record 17-time Grand Slam title winner beat the six-time major champion 3-6, 6-3, 6-2, turning the match around not only with scintillating groundstroke hitting but with some bold approaches to the net.
Djokovic looked the more likely winner when he got within a point of going a break up in the fifth game of the second set, but a couple of minutes later came a short rain delay which halted his momentum.
After that Federer's game rose to much higher levels, and his increasing willingness to come forward, which earned him 11 points from 17 net forays, seemed to bear the stamp of his new coach, Stefan Edberg.
"There was a buzz out there tonight, and I was able to enjoy myself with that crowd," five-time Dubai champion Federer said on court.
"For some reason I had a tough start but the crowd kept pushing me on and I played well. It's a quick court so I am always trying to be aggressive. I wish I could do Stefan's volleys, but I work with what I have."
Later the 32-year-old was asked when he might be back to his best again, after a difficult 2013.
"I hope it's now," he said. "It's all happening. Beating Novak on the hard courts here in Dubai, it's tough. This is a big step in the right direction for me. It gives me a lot of confidence."
Federer also improved what he calls his transition game -- the strokes and timing which facilitate his movement to the forecourt -- and from late in the second set he generated a spell of six winning games out of seven.
Djokovic may have suffered from lack of match practice -- this was only his third match since losing his Australian Open title more than five weeks ago, and although he played some great counter-hitting rallies he never looked like stopping Federer when he was on a roll.
- Federer, crowd believed he could win -
Returning at love-30 on his serve after the rain, Djokovic immediately hit a backhand drive into the net, and lost that pivotal game when he failed to land his first serve and followed it with another drive into the net.
The first game of the final set saw Djokovic drop serve again with a double fault, which was also crucial, making both Federer and the crowd believe he could win.
Although Djokovic did play his part in a sensational eight-minute fifth game in the final set, he could do nothing about a roaring forehand cross court pass with which Federer achieved a double break.
"I knew I was in a bit of trouble and not looking good at all because he has a tendency to really run with it and then play more freely on your serve and he plays very dangerous," said Federer, who had lost three matches in a row to Djokovic before Friday.
"So for me it was just a matter of trying to play consistent but remain aggressive. Sometimes be also overly aggressive and see if it works."
When it did, it put him 17-15 up in their head-to-heads and prevented Djokovic earning a repeat of last year's final against Tomas Berdych, the world number six from the Czech Republic.
Djokovic said Federer was an eventual worthy winner.
"Even though I was the better player and I felt I was in control for the first hour or so, that was not enough, because a few points can really decide the winner and it can change," said the world number two.
"Congratulations to him for coming back into the match. He deserved to win."
Berdych reached the final with a 7-5, 7-5 victory over Philipp Kohlschreiber, the seventh-seeded German, earning him his 16th win in 17 matches.