Roger Federer fought back from two sets down and saved two match points to defeat Gael Monfils in a dramatic US Open quarter-final.
Monfils pushed Federer right to the limit under the lights on Arthur Ashe and looked to be on the verge of victory with his opponent at 4-5 and 15-40 in the fourth set.
But Federer hung on and raced through the final set against an opponent who had given everything to win 4-6 3-6 6-4 7-5 6-2 and set up a last-four clash with Marin Cilic.
It is the ninth time in his career that Federer has won a match from two sets down and puts him within two victories of a first US Open title since 2008.
The 33-year-old, who will now overtake Rafael Nadal to regain the world number two spot, said: "Gael put up such a great fight and played such incredible tennis.
"But I still thought the finish line was far and I knew I could play better tennis. When I was down two match points I wasn't feeling so great.
"I thought, 'This is it. Last point man. Just go down fighting, don't miss an easy shot and let him have it'. I served well and stayed in the match and somehow turned it around.
"I felt great in the fifth, I was playing better and better and it was a great feeling."
Somewhat surprisingly, it was Monfils who came into the match without having dropped a set during the tournament.
The biggest shock about the mercurial Frenchman's victory over Grigor Dimitrov in round four had been how calm and controlled he had been - one minor meltdown aside.
There was more of the flamboyant Monfils from the start against Federer but not to the detriment of his tennis, as has so often been the case.
The Frenchman's mixture of casualness, power and incredible athleticism meant Federer could not get into a rhythm, and he lost his serve in the fifth game.
It was Federer's shot selection that left plenty to be desired and he was in big trouble when he dropped serve again at the start of the second set on an ill-advised drop shot.
The crowd were waiting for Federer to find a way back in but instead he was broken a second time to lose the set, netting a routine backhand.
Federer had won seven of their previous nine matches but only two of the last four, all of which had been close.
He desperately needed a good start to the third set and he got it, at last penetrating Monfils' remarkable defence with two big forehands.
Back came the Frenchman to level at 2-2 with a backhand pass that caught the line but Federer forged ahead again immediately, upping the aggression by attacking the net more frequently.
And by the time Federer put a forehand away to win the set, he was looking much more at home again.
The Swiss had only lost one previous night match at the US Open, against Tomas Berdych in the quarter-finals two years ago, and he set about trying to level proceedings by breaking in the third game of the fourth set.
But Monfils would not let him get away, the Frenchman for the most part maintaining his very high level and forcing Federer into uncomfortable positions.
The second seed took his frustration out on umpire Carlos Ramos, but it was himself he was most upset with.
Monfils kept his nose in front and, with Federer serving to stay in the match at 4-5, brought up two match points.
The tension was clear but Federer kept his cool, a big serve doing the damage on the first before Monfils just missed with a backhand, and a thumping forehand taking care of the second.
Federer celebrated and a game later he was serving for the set after Monfils sent down his eighth and ninth double faults of the match to hand over the break.
The odds were now firmly in Federer's favour and Monfils played the fifth set like a man who knew his time had come and gone.