Novak Djokovic took on Roger Federer for the 38th time in his career in the Indian Wells final on Sunday. Reuters

Novak Djokovic won the BNP Paribas Open at Indian Wells on Sunday, outlasting Roger Federer 6-3, 6-7 (5), 6-2. Djokovic’s win came in an exciting back-and-forth match and marked a second straight Indian Wells title over Federer.

The win earned world No. 1 Djokovic his fourth Indian Wells crown, adding to victories in 2008, 2011 and 2014. The fourth title ties Djokovic with—whom else—Federer for the most all time. The 27-year-old now has 50 tour-level titles, just one of 12 players in history to accomplish the feat. He earned the win, fighting back after getting shocked by a second-set Federer comeback.

“I was a bit more up and down. [Djokovic] was more solid," Federer said in a press conference after the match. "That's why he totally deserves this win”

Djokovic garnered a bit of revenge for a loss he suffered to Federer last month in Dubai. The star knows that playing against Federer means a win is never guaranteed.

“I don’t take anything for granted,” Djokovic said after winning the title.

The Serbian took the first set 6-3 over Federer and looked like he was going to win the second set, and the championship, when he raced ahead going up 4-3. World No. 2 Federer fought back, seeming to gain new life after a stunning forehand winner when he was still down 3-4. Federer then rattled off eight straight points to go up 5-4. The pro-Federer crowd rose to its feet in ovation after he took the lead. Djokovic battled back and eventually forced a tiebreak, but subsequently double-faulted three times in the breaker. Federer persisted well and was able to force the deciding set.

After the stunning comeback in front of a crowd that was decidedly pro-Federer, it appeared that Djokovic was destined to miss out on his 50th title. But the star showed why he is such a quality tennis player by battling to win. Djokovic settled in and wore Federer down. The Swiss legend double faulted at a critical juncture to allow Djokovic to go up 4-2. Another comeback was simply too much to ask of Federer as his counterpart cruised through the final two games. Djokovic earned his fourth Indian Wells title when Federer sent a forehand wide to give up the championship point.

Federer still holds a career 20-18 record against Djokovic in their 38 career matches, but that likely did little to ease the defeat.

“I think [Djokovic] found an extra gear in the end,” Federer said in the press conference. “It was tough. I enjoyed the match. It had a bit of everything.”

Tweets/Video via TennisTV