The 19th Grand Slam title that seemed so inevitable for Rafael Nadal during the first two-plus sets of the U.S. Open final suddenly seemed in doubt as Daniil Medvedev forced it to a fifth.

What had all the makings of a crowning morphed into a real contest thanks to Medvedev, a man a decade younger and appearing in his first major final. Medvedev shifted styles, upped his level and received an unexpected boost from Arthur Ashe Stadium spectators.

Truly tested for the only time in the tournament, the No. 2-seeded Nadal managed to stop Medvedev's surge and hold off his historic comeback bid, pulling out a 7-5, 6-3, 5-7, 4-6, 6-4 victory in 4 hours, 50 minutes of highlight-worthy action and feature-film-worthy drama on Sunday, collecting his fourth championship at Flushing Meadows.

Nadal is now within one major trophy of Roger Federer's record for Grand Slam titles won by a man. But this one did not come easily. Not at all.

Sure seemed it might, with Nadal ahead by two sets and a break in the third at 3-2. But the No. 5-seeded Medvedev, a 23-year-old from Russia, did not go gently into the night. He broke right back to 3-all, then again to claim that set and yet again to end the fourth.

Not since 1949 had a man won the U.S. Open final after trailing by two sets to one. Never before had Medvedev won a five-set match. Only once before had Nadal lost a Grand Slam match after taking the opening two sets.

And yet the drama here was real.

Even at the very end -- or when everyone, save Medvedev, perhaps, figured it was the very end -- Nadal had trouble closing things out. After breaking to lead 3-2 in the fifth, in a game Medvedev led 40-love, Nadal broke again and served for the championship at 5-2.

The way this back-and-forth tale was spun, though, it probably was inevitable that Medvedev would break there. And so he did, because Nadal double-faulted on break point after he was docked a serve for his third time violation of the evening.

In the next game, Nadal held a pair of match points, but Medvedev, of course, avoided defeat yet another time, erasing one of those with a backhand winner, the other with a service winner.

With fans screaming, "Close it out!" at the ensuing changeover, Nadal once more stepped to the baseline to try to serve it out, this time at 5-4. Naturally, he was forced to deal with another heart-in-throat break point, but came up with a stinging forehand that drew a long forehand from Medvedev.

Two points later, it was over, and Nadal was splayed on his back on the court, the victor at Flushing Meadows for the fourth time.

Add the Spaniard's haul in New York to his 12 titles at the French Open, two at Wimbledon and one at the Australian Open, and the 20-19 gap between Federer and Nadal is the closest it's been in 15 years. Federer led 1-0 after his breakthrough triumph at the All England Club in 2004, and he had four by the time Nadal got his first at Roland Garros in 2005.

ANTONIO BROWN USED SOCIAL MEDIA CONSULTANTS TO ACCELERATE RELEASE FROM RAIDERS, REPORT SAYS

Federer, who lost in the quarterfinals at the U.S. Open, is 38, while Nadal is 33 -- making him the oldest male champion at Flushing Meadows since 1970. He's also the first man to win five majors after turning 30.

Nadal says he wants to finish his career at No. 1 in the Grand Slam standings -- ahead of Federer and Novak Djokovic, looming in third place currently with 16 -- but also insists he won't base his happiness on how it all shakes out in the end.

This one ended the way he wanted it to. The journey just took more detours than anyone could have anticipated.

Perhaps sensing the end was near, Medvedev turned into a trickier foe. He alternated serve-and-volley surprises with a penchant for out-hitting Nadal at the baseline. For a stretch, it felt as if Medvedev simply could not miss.

It was the kind of ball-striking and shape-shifting Medvedev showed while going 20-2 during the North American hard-court circuit, reaching four finals in a row.

CLICK HERE TO GET THE FOX NEWS APP

The Flushing Meadows fans that jeered Medvedev in Week 1 because of his on-court behavior -- he trolled his detractors by sarcastically thanking them and telling him their vitriol was why he won -- were pulling for him.

Or, at least, pulling for more bang for the bucks they spent on tickets.

They certainly got that.