Just when it looked like it wouldn’t be one, the Russian meteor Daniil Medvedev made a match of what became a U.S. Open final five-set classic.

And it was much to the chagrin of 33-year-old Rafael Nadal, 10 years Medvedev’s elder.

But Nadal’s great warrior spirit rose up once again, and he added a new storied chapter to his legacy after a 4-hour, 50-minute epic that brought him to tears.

As he gets so close to Roger Federer, he’s starting to resemble him. The 33-year-old Spanish baseliner tossed in a pinch of serve-and-volley and net play to win the first two sets. Then Nadal survived the incredible late onslaught of the spin master from Russia to win his fourth U.S. Open title.

It goes down as the third-longest Open final in history — 7-5, 6-3, 5-7, 4-6, 6-4 Sunday at Arthur Ashe Stadium. Nadal moved one major away from Federer’s record of 20 Grand Slam titles — and one away from Federer’s U.S. Open haul of five.

Nadal flopped to his back for 30 seconds before the post-match handshake. It looked like he would never rise, but when he did, he bounded up with tears in his eyes.

Before the championship ceremony, a video played recapping all of Nadal’s 19 Slam titles, and the Spaniard watched it from his chair with tears rolling down his face before he buried his head.

Nadal called it a “crazy match” during the championship ceremony. “One of the most emotional nights of my tennis career with that video,’’ Nadal said. “I tried to hold the emotion, but some moments was impossible. Daniil created this moment, too. The way he fought, the way he played, is a champion way.

“He has a great, great future in front. I really believe that. Of course, he will be able to win Grand Slams, a couple of them, no?”

Indeed, this battle was also about the 23-year-old Medvedev, despite a quad injury, announcing his arrival in Flushing as a major-title threat to the Big 3 with that deceptive, sweeping two-handed backhand that ultimately turned early-tournament boos to cheers.

Down two-sets-to-love and a break, Medvedev earned the adoration of the Flushing fans with his terrific rally to force a fifth set. He admitted after being a break down in the third set he was already thinking what he’d say in the post-match speech.

“It’s an amazing story,’’ Medvedev said of his summer rise. “I’ll remember every moment of it.”

Seeded fifth, Medvedev cleaned up during the summer hard-court season with his assortment of angles and spins but entered the Open never having gone past the fourth round of a Grand Slam. He wasn’t ready to beat a legend on the biggest stage. But he came awfully close after moving to 0-5 in five-set matches. (Nadal is 22-12).

The boos started early in the tournament after he gave the middle-finger salute to the fans after they got on him for ripping a towel from a ball boy. Sunday night, he again apologized and thanked them for boosting his energy in his comeback versus Nadal, even chanting his name in the fourth and fifth sets.

“I was fighting for every point,’’ Medvedev said. “I think they appreciated it.”

While his array of drop shots didn’t work at all against Nadal early, the Russian got locked in late and became a wall.

In the fifth, Rafa came on despite being flagged for two service-clock violations that cost him two first serves — one that caused a double fault on a break point. After the first violation, Nadal smoked a crushing forehand winner and swung his arms wildly to exhort the crowd once more.

On the key service break in the fifth, at 2-2, Nadal fell behind 40-0 but stormed back, racing in for a drop shot to pummel a winner. When he closed out the match on serve, he hit a ridiculously surprising and effective drop shot at 30-30 that the Russian couldn’t retrieve.

The greatest clay-court player ever is now favored to one day surpass Federer, considering the 33-year-old could have two French Open titles left in him. Nadal already has 12 titles on the Paris red clay.

The so-called Big 3, which includes Novak Djokovic, has won every Grand Slam since the 2016 U.S. Open claimed by Stan Wawrinka.

The Open set an all-time attendance record in 2019, with 737,872 fans in the two weeks of the main draw, but Sunday’s final crowd got the best value.