INDIAN WELLS, Calif. — Rafael Nadal's serve deserted him in the second set, and so did his chances of beating a streaking Novak Djokovic.

INDIAN WELLS, Calif. — Rafael Nadal's serve deserted him in the second set, and so did his chances of beating a streaking Novak Djokovic.

Djokovic defeated the world's top-ranked player 4-6, 6-3, 6-2 to win the BNP Paribas Open title on Sunday, keeping the Serbian perfect this year.

Djokovic improved to 18-0, including victories at the Australian Open and in Dubai last month.

"It definitely says good things. I am playing with a lot of confidence. I'm feeling the ball well on the court," he said. "I'm very dedicated. I have a big will to win each match. I want to keep on going and keep on playing good tennis."

Djokovic will move into the No. 2 spot when the ATP Tour rankings are released today, having bumped Roger Federer down to third after he lost to Djokovic in the semifinals. Nadal will remain No. 1 with a 14-3 record.

After Nadal's forehand hit the net on match point, Djokovic threw his head back and let out a prolonged yell while pumping both arms.

His Monte Carlo neighbor, top-ranked Caroline Wozniacki, defeated 15th-seeded Marion Bartoli 6-1, 2-6, 6-3 to win the women's title a year after the Dane lost in the final.

Djokovic became just the third player to beat Nadal and Federer in the same tournament twice, having last done it at Montreal in 2007. That year, Djokovic lost to Nadal in the final at Indiana Wells, then won in 2008.

Wozniacki won her WTA Tour-leading 19th match of the year and her second title while appearing in the final for her third consecutive tournament.

Wozniacki won on her second match point when Bartoli's backhand sailed beyond the baseline. Bartoli was playing in her first final since 2009, and she fell to 2-6 in matches against the No. 1 player.

The victory allowed Wozniacki to improve her results for the fifth straight year in the desert. She lost in the first round in her 2007 debut, reached the fourth round in 2008, the quarterfinals in 2009 and was runner-up to Jelena Jankovic a year ago.