Close to quitting tennis after four wrist surgeries in recent years, the Argentine fought to get back to the ATP Tour even as he was reduced to hitting his backhand with one hand instead of his usual two.

The struggle paid off Sunday, when Del Potro staved off three match points in the third set to beat top-ranked Roger Federer 6-4,7-6 (8), 7-6 (2) for the BNP Paribas Open title.

The win ranks up there with Del Potro's 2009 U.S. Open title, in which he beat Federer, and helping Argentina win the Davis Cup in 2016.

"I cannot believe I won this tournament, beating Roger in a great final and level of tennis," Del Potro said.

Naomi Osaka of Japan won the women's title 6-3, 6-2 over Russian Daria Kasatkina in a match-up of 20-year-old rising stars.

Del Potro and Osaka each earned $1.3 million.

Del Potro became the first Argentine champion in the 42-year history of the desert tournament. He handed Federer his first loss of the year, snapping the Swiss superstar's 17-match winning streak that was the best of his career.

"I feel frustrated that I let an opportunity like this go by," Federer said.

Del Potro held a match point at 8-7 in the second-set tiebreaker, but he lost the final three points on his own errors that allowed Federer to force a third set.

"It was a lot of frustration after that match point, but then I play well," Del Potro said.

They were on serve in the third until Federer broke for a 5-4 lead with a backhand winner off del Potro's serve.

Federer had a chance to serve out the match, holding two match points. But del Potro staved both off to force deuce.

Federer's forehand went long, giving del Potro a break point. Federer answered with a backhand that hit del Potro at the net and then gained his third match point on del Potro's forehand error.

Del Potro recovered to deuce with a forehand winner. Federer mis-hit a forehand high into the air beyond the baseline, giving del Potro another break point. The Argentine cashed in with a well-placed forehand in the corner to tie the set, 5-all.

In the tiebreaker, Del Potro raced to a 6-1 lead, helped by two of Federer's double faults. He closed out the win on his third match point when Federer's forehand failed.

"I would like to play that tiebreaker again because I don't know what the hell happened," Federer said.

Del Potro lost just six points on his serve in the first set.

In the second-set tiebreaker, Del Potro and Federer took turns arguing with chair umpire Fergus Murphy. Del Potro was annoyed the crowd was making noise on his serve and told the umpire he wasn't warning them enough to be quiet.

"It had no effect on the outcome of the match," Federer said. "I was just also just trying to pump myself up more, to get energy for me."

Del Potro survived three-setters against countryman Leonardo Mayer in the fourth round and Philipp Kohlschreiber in the quarterfinals. It was his first win against Federer since last year's U.S. Open quarters. Del Potro trails in their series 18-7, but owns a 4-2 advantage in finals.

Del Potro arrived at Indian Wells having won a title in Acapulco and back in the top 10.

"I'm really enjoying playing tennis again," he said. "I'm still surprising myself, and I want to keep surprising the tennis tour."