Novak Djokovic twice had to come from a set down to see off Stanislas Wawrinka 2-6 7-6 (7/4) 3-6 6-3 6-4 on his way to reaching the final of the US Open for the fourth successive year.
The Serbian was pushed to the limits by the ninth seed in a titanic battle on Arthur Ashe that included one game that lasted 21 minutes.
Wawrinka, who had knocked out reigning champion Andy Murray to reach the last four, took the opening set 6-2 and despite letting slip a lead in a second that was eventually lost on a tie-break, recovered to move ahead again.
Crucially, though, the Swiss was unable to put the top seed away, with Djokovic taking the fourth set 6-3 and then gaining a crucial break in the decider.
"These matches are what we live for, what we practise for," said the 12-time grand slam finalist after a match that lasted four hours and nine minutes.
"It was obvious that Stan played more aggressive, he played better tennis. I was trying to hang in there, trying to adjust. I had to run a lot, I wasn't playing as well as I wanted but all the credit to him for playing so well.
"I was so fortunate to play my best tennis when I needed to."
Djokovic - who had also beaten the same player in five at this year's Australian Open - is well known for his physical powers of recovery but also had to show tremendous mental strength to survive an early onslaught from Wawrinka.
The first set was a shocker for last year's beaten finalist that saw him lose his serve three times, while he seemed to be struggling in the second - which included receiving a warning for coaching - when he slipped 4-2 behind.
However the world No 1 levelled at 4-4 and went on to take a high-class tie-break, clinching the set at the second opportunity thanks to a cross-court forehand winner.
The third set saw something of a lull in the quality but it still came as a surprise when Djokovic inexplicably played a terrible game to be broken to love and fall behind again.
His response was to break immediately at the start of the next, and the tension seemed to be getting to his opponent as he earned a point penalty for not only smashing his racket on the ground but also then snapping it in half over his knee.
Physically Wawrinka was also showing signs of weakness; a medical time-out was required, but he showed no sign of injury when he held firm in a quite remarkable third game of the fifth set that had no fewer than 12 deuces.
Djokovic channelled his frustration in wasting five break-point opportunities by breaking at the next attempt, giving him a lead he would retain right through to the finish. He finally put paid to Wawrinka with an ace.
He will now face second seed Rafael Nadal - who he has met twice before in the final, with each man triumphing once - on Monday in New York.