It was past 1am in New York when the world number one finally finished off a 7-6 (7/1) 6-7 (1/7) 6-2 6-4 victory after three hours and 32 minutes to move forward to a semi-final against Japan's Kei Nishikori.
The considerable consolation for Murray was that he played his best tennis since back surgery almost a year ago and looks close to the form that brought him two grand slam titles.
Djokovic said: "We both gave our best. At times the tennis was not that nice, we made a lot of unforced errors, but it was due to the very physical battle in the opening two and a half sets.
"I didn't expect any less knowing I was going to face Andy. The last five times we played, it was always over three or four hours. I'm very glad to get through to another semi-final."
This was easily the most eagerly-awaited clash of the tournament so far and a match-up that has decided four grand slam finals - both men winning two each.
Murray had the advantage of having won their only previous meeting here, when he broke his grand slam duck in 2012, and their last grand slam match, last summer's career-defining Wimbledon win.
There was no doubt he was the underdog this time, though, with Djokovic back at world number one, the Wimbledon champion and through to the last eight without having dropped a set.
Murray had spent three and a half hours longer on court in his first four matches but the form he showed in beating Jo-Wilfried Tsonga two days before had fuelled cautious optimism.
The New York crowd settled in for a long night as Djokovic began the contest at 9.43pm with a second serve that was dispatched past him by a fizzing Murray backhand.
The Scot carried the momentum to an immediate break but it quickly became clear service breaks would not be at a premium.
From 1-0 up, Murray found himself 4-1 down only to fight back to level.
Murray urged the crowd to be louder still as he tried to break in the ninth game but Djokovic held on, winning an amazing 29-shot rally and piling the pressure on his opponent.
Murray held twice to force a tie-break but made a poor start, trailing 4-0, and never recovered.
Murray had never beaten Djokovic from a set down and the world number one had never lost a match at Flushing Meadows from a set up, so the odds were firmly in his favour now.
Djokovic's record in New York is seriously impressive, with the 27-year-old looking to reach an eighth consecutive semi-final and a fifth straight final.
Murray looked in serious trouble when he dropped serve meekly in the third game of the second set but after three more service breaks they were level again at 4-4, Djokovic no doubt unamused by a time violation warning from umpire Pascal Maria.
Djokovic saved a set point at 5-6 to force a second tie-break, which had exactly the same pattern as the first but the other way around.
Murray looked to have the momentum and began the third set brilliantly, his flat, flashing forehand cutting Djokovic to pieces.
But he took his foot off the gas in the fourth game to go behind for the third successive set.
He had two chances to break back but this time his forehand just missed its target and Djokovic broke again to take a much more straightforward set.
Djokovic looked like the man who had won the big matches this season but Murray was certainly not out of it.
He had another break point in the opening game of the fourth set but Djokovic saved it, as he had all but four of the 16 chances Murray had had.
The extra time he had spent on court looked to be catching up with the eighth seed, who suddenly looked extremely tired.
He held serve surprisingly easily for the most part despite his back appearing to have tightened up, meaning he could not hit the ball at more than 100mph.
But with Murray serving to stay in the match at 4-5, Djokovic sensed his chance and sealed the victory when his opponent netted a backhand.