Federer rallied from a break down and a 5-3 deficit in the third set to force the tiebreaker, but he made a slew of mistakes to lose the 33rd meeting between the rivals.
Federer still leads the series 17-16, having beaten Djokovic in three sets in the semifinals at Dubai two weeks ago. Djokovic will remain No. 2 in the world, while Federer will rise three spots to No. 5 on Monday in the ATP Tour rankings.
Flavia Pennetta routed injured Agnieszka Radwanska 6-2, 6-1 to win the women's title, the biggest of her career.
Federer was trying to win a record fifth title in the desert, and at 32, he would have been the oldest Masters 1000 winner since 34-year-old Andre Agassi won at Cincinnati in 2004.
But Djokovic wouldn't allow it.
After Federer breezed to the first set in 31 minutes, Djokovic settled down and locked into the punishing rallies that marked most of the match. He earned the lone break of the second set to go up 5-3 after Federer pulled a forehand wide.
Djokovic got the early break in the third, again on one of Federer's forehand errors, to lead 2-1. His 112-mph ace gave him a 4-2 lead, and he extended it to 5-3 with a backhand winner down the line.
Federer served a love-game to trail 5-4 and then broke Djokovic on a forehand error to tie the set, 5-5. Federer held at love again and Djokovic gave up just one point on his serve for a 6-all tie.
The Serb raced to a 5-1 lead in the tiebreaker, helped by four errors from Federer. Another of Federer's forehand errors gave Djokovic a 6-2 lead before the Swiss star's ace ensured Djokovic would have to win the match on his serve. He did, when Federer's backhand landed in the net.
Djokovic's victory evened their rivalry on hard courts at 13 wins apiece.