Rafael was made to work for his fourth US Open Title, racing into a two-set lead before being pegged back by Daniil Medvedev, before eventually winning 7-5, 6-3, 5-7, 4-6, 6-4 to triumph at Flushing Medows on Sunday evening.
The 33-year-old Spanish left-hander moved one shy of Roger Federer's all-time men's record 20 Grand Slam triumphs and became the second-oldest New York champion in the Open era after Ken Rosewall in 1970 at age 35.
Nadal took the top prize of $3.85 million at Arthur Ashe Stadium and added to his US Open trophy haul from 2010, 2013 and 2017. Nadal, who was in his fifth US Open championship match and 27th Grand Slam final, is the first man to claim five major titles after turning 30.
But it took a supreme effort from the Spanish maestro, who nearly became the first player to drop the final after leading by two sets since Ted Schroeder in 1949.
Nadal, who rose to 22-12 in five-set matches, only lost once at a Slam when up two sets, to Italy's Fabio Fognini in the 2015 US Open third round.
"I more or less had the match under control," Nadal said. "The way he was able to fight, to change the rhythm of the match, was incredible."
At four hours and 50 minutes, the match finished four minutes short of equaling the longest final in US Open history from Mats Wilander's 1988 win and Andy Murray's 2012 title.
It was the second Slam title of the year for Nadal after taking his 12th French Open crown in June. In addition to reaching the brink of Federer's mark, Nadal moved one shy of the Open era record five US Open titles won by Federer, Jimmy Connors and Pete Sampras.
"A 19th Grand Slam title is something unbelievable, outrageous," Medvedev said.
Nadal, who won his only prior meeting with Medvedev in last month's Montreal final, stretched his win streak over Russians to 20 matches since losing to Nikolay Davydenko in the 2011 Doha semi-finals.
Fifth seed Medvedev, 23, would have been the youngest men's Grand Slam champion since Juan Martin del Potro at the 2009 US Open.
Medvedev, who will rise to a career-best fourth in the rankings, was a champion at Cincinnati and runner-up at Montreal, Washington and the Open.
On a knife's edge at 5-5 in the third set, Medvedev reeled off eight of the last nine points to force a fourth, breaking Nadal in the 12th game with a backhand winner.
"To be honest in my mind, I was already thinking, 'What do I say in the speech, it's going to be in 20 minutes," Medvedev said. "I was like I have to fight for every ball, and it went further but it didn't go my way."
Nadal was broken in the 10th game of the fourth set to force a fifth when Medvedev blasted a sterling backhand return winner. Nadal rescued three Medvedev break chances to hold in the second game of the fifth set, fired a backhand volley winner to break Medvedev in the fifth game and seized a 5-2 edge when Medvedev hit an overhead smash long.
Serving for the match, Nadal was broken when umpire Ali Nili issued Nadal a time violation for his first serve and the Spaniard sent his second long, the crowd booing Nili for his call.
Nadal squandered two break and match points in the ninth game as the drama intensified. Again serving for the match, Nadal rescued a breakpoint then hit a forehand drop volley for his third match point chance and Medvedev sent a forehand return long to end matters. Nadal screamed and fell to the court on his back in joy and exhaustion.