MELBOURNE, Australia (AP)—In certainly the longest and arguably one of the greatest Grand Slam singles final in the history of professional tennis, Novak Djokovic outlasted Rafael Nadal over 5 hours, 53 minutes to win a third Australian Open title.

The players walked on court at 7:30 p.m on Sunday and it was 1:37 a.m. on Monday by the time Djokovic completed a scarcely believable 5-7, 6-4, 6-2, 6-7 (5), 7-5 win.

Minutes earlier, at 4-4 in an electrifying fifth set, an exhausted Djokovic had been spread-eagled on the court after losing a 31-shot rally—the longest of the match. He seemed barely able to pick himself and his racket up, but he somehow lifted himself for one last effort, beating Nadal for the seventh time in a final since March.

The 24-year-old Djokovic tore off his shirt in celebration. He went to his support camp and repeatedly thumped the side of the arena in front of them in delight and relief.

As the players waited for the trophy presentation, Nadal leaned on the net, while Djokovic sat on his haunches. Eventually, a nearby official took pity and they were given chairs and a bottle of water each.

“We made history tonight and unfortunately there couldn’t be two winners,” said Djokovic, the winner of five Grand Slam titles and four of the last five majors.

Djokovic became the fifth man since the Open Era began in 1968 to win three straight Grand Slam finals, joining Nadal, Roger Federer, Pete Sampras and Rod Laver.

In the most devastating of circumstances, Nadal became the first man in the Open Era to lose three straight major finals. He was beaten in four sets by Djokovic at last year’s Wimbledon and U.S. Open.

“I think we played a great tennis match. I enjoyed being part of this event and this match,” Nadal said. “I am not happy to lose the final, yes, but that’s one of the losses that I am more happy (about) in my career.”

Having reduced Roger Federer to tears when he won the title over five sets in 2009, Nadal managed to maintain his composure during the on-court speeches— and even managed a joke.

“Good morning, everybody,” Nadal said, earning laughs and loud applause from the crowd. “Congratulations to Novak and his team. They deserve it. They are doing something fantastic, so congratulations.”

The previous longest major singles final was Mats Wilander’s win over Ivan Lendl at the U.S. Open in 1988, which lasted 4 hours, 54 minutes.

The longest Australian Open final also involved Wilander in 1988, when the Swede beat Pat Cash. Sunday’s match was also the longest in the tournament’s history.

A tense, error-strewn opening set offered no indication of the high drama to follow. In hot, humid conditions, Nadal, trying to step up to the baseline to take the initiative, took it after 80 minutes—two minutes short of the entire women’s final the previous day.

Nadal had only lost one match of his previous 134 in Grand Slams after winning the first set, but he found his serve coming under increasing pressure as the match wore on.

As if to demonstrate the pervading tension of the occasion, Djokovic double-faulted at break point down while serving for the second set at 5-3 before Nadal returned the favor by double-faulting in the next game to give the Serb the second set.

By the time Djokovic took a 3-1 lead in the third set, Nadal’s shoulders were visibly slumping and he was talking to himself more often, unable to stop his opponent peppering the baseline with his returns to take control of the points.

At 5-2, his uncle and coach Toni Nadal moved to the front row of the players’ box to try to get some positive messages to his nephew. It didn’t work. Nadal lost his serve again—at love.

But in the fourth set, Nadal dug in, drawing on his renowned fighting spirit, and the match really came alive when he recovered from 0-40 down in the eighth game with two spectacular winners, two unreturnable serves and an ace.

The crowd erupted into a chant of “Rafa, Rafa, Rafa, Rafa.” Then came a rain shower and a brief delay for the roof to close, adding another twist to the unfolding tale.

Nadal regained regained his momentum in the tiebreaker, reeling off four straight points from 5-3 down—and two points from defeat—and taking the match into a decider when Djokovic’s forehand dropped wide.

The tennis, almost unbelievably, improved in the fifth set as the match ticked past five hours.

Nadal went up a break at 4-2 and Djokovic seemed to finally be feeling the effects of his nearly five-hour semifinal against Andy Murray on Friday.

But the No. 1-ranked Djokovic responded immediately, finding another brutal return on break point in the next game to force the error from Nadal.

Past midnight and with a working day looming, the Rod Laver Arena remained almost full, no one wanting to miss the finale of a now historic occasion.

Nadal saved a break point at 4-4 and then another at 5-5. Djokovic came again though. On a second break point, he forced Nadal to net a backhand, giving him a chance to serve out the match.

Still, Nadal wasn’t quite done. Djokovic had to save a break point with a crosscourt backhand, looking to the sky and crossing himself as he limped back to the baseline, before finally claiming victory with his 57th winner of the match.