(CNN) -- Novak Djokovic cemented his status as the hottest tennis player on the planet this year with a superb 4-6 6-3 6-2 victory over world No. 1 Rafael Nadal in the final of the Masters Series event at Indian Wells on Sunday.
The Australian Open champion claimed Roger Federer's No. 2 ranking when he beat the 16-time grand slam champion for the third time in 2011 in Saturday's semifinals, and followed that up with his first win over Nadal since 2009.
The Serbian claimed the 21st title of his career, and his second at Indian Wells, as he avenged his 2007 final defeat to Nadal in the Californian desert in a match lasting two hours and 25 minutes.
The Spaniard, playing his first tournament since suffering a hamstring injury in his quarterfinal defeat in Melbourne in January, also beat Djokovic in the final of last year's U.S. Open to complete his career grand slam.
He was seeking to join Federer, Michael Chang and Jimmy Connors as the only players to win three times at Indian Wells.
And it looked like the 24-year-old was on course for his 46th ATP Tour title after clinching the first set after a vital break in the seventh game, as he served out to love.
But Djokovic, who had been punished on his second serve in the opener, battled back to take a 4-2 lead.
Nadal immediately broke back, but then lost his own serve again, and Djokovic finally leveled at 1-1 after his opponent hit wide of the line as he tried to save a sixth set-point.
Nadal's error rate grew alarmingly in the deciding set, and Djokovic romped to a 4-0 lead as his serve got stronger as the match went on to extend his unbeaten run to 18 matches this year.
The 23-year-old claimed the $605,500 first prize after becoming only the third player to beat Nadal and Federer in the same tournament twice, joining Nikolay Davydenko and David Nalbandian.
However, Djokovic -- who spent 26 weeks at second in the rankings last year -- will still be almost 4,000 points behind Nadal when the ATP rankings list is released on Monday.
"I lost today, but I lost to one of the greatest," said Nadal, whose last title came in Japan last October.
Meanwhile, women's No. 1 Caroline Wozniacki claimed her second title of the year after beating Marion Bartoli 6-1 2-6 6-3 in the WTA Tour final at the same venue earlier on Sunday.
The 20-year-old Dane captured the 14th crown of her short career as she survived a second-set fightback from the first Frenchwoman to reach the Indian Wells final.
Wozniacki, the runner-up last year, handed 15th seed Bartoli her seventh defeat in 12 career title matches.
"This is such an amazing event and everyone loves playing here. I'm already looking forward to playing here next year," Wozniacki said.
Bartoli, the 2007 Wimbledon runner-up, is set to return to the top-10 in the rankings when the new list is released.
"Caroline, you should be very proud of yourself and I wish you all the best in the future. I know your goal is to get a grand slam -- I'm sure you'll get it very soon," she said at the award ceremony.