After winning the first two sets against the Serb, it looked like another chance was slipping through the Scot's fingers when the 2011 champion forced a decider but Murray came through 7-6 (12/10) 7-5 2-6 3-6 6-2.
In a twist of fate, Murray's victory came 79 years to the day since Fred Perry won his first grand slam title at the US Open and ended Britain's 76-year wait for a men's singles grand slam champion.
The 25-year-old also became the first man in history to win Olympic singles gold and the US Open in the same year and emulated coach Ivan Lendl in winning his first grand slam trophy at his fifth attempt.
"Right now, there's a lot of relief and I'm still buzzing a bit from the match - the atmosphere out there was unbelievable," he said afterwards.
"It would have been a tough one to lose so I'm so, so happy I managed to pull though in the end.
"The body's hurting a bit but it was worth it."
The final was put back a day for the fifth straight year because of bad weather on Saturday, when Murray had coped well in almost unplayable conditions while Djokovic had not before his match against David Ferrer was suspended.
The wind was certainly the dominant factor in the early stages as the pair exchanged breaks but Murray was again dealing with it better and he moved 4-2 ahead only for Djokovic to fight back.
The James Bond theme played as Sir Sean Connery was shown on the big screen while Sir Alex Ferguson also arrived, with the Manchester United manager sitting in Murray's box.
The two Scottish knights had gatecrashed Murray's press conference on Friday to congratulate their countryman, and he certainly needed the support now.
The rallies got ever longer and more intense and a tie-break was needed to separate them, which turned out to be suitably epic.
Murray was playing catch-up all the way until he had the first set point at 6-5, which Djokovic saved with a gutsy smash.
It was a pattern that was to become all too familiar as four more times Murray created set point only to miss his opportunity before, on the sixth chance a serve did not come back.
It was only the second set Murray had ever won in a grand slam final and, like the Wimbledon final against Roger Federer, it was the opening set he took.
He went on to lose the next three that day but Djokovic was rattled and Murray reeled off four games in a row at the start of the second set.
The Serb retrieved one break immediately, which seemed a minor detail until Murray faltered serving for the set and was broken again.
It was a big blow after he had held such a commanding lead, and Djokovic was now well and truly out of his slump and pushing to level the match.
But Murray held for 6-5, celebrating with a yell of 'come on', and it proved a key moment when in the next game Djokovic missed a smash to hand his opponent two set points.
Arthur Ashe roared and, although he saved one with a good serve, a forehand wide sealed it for Murray.
This was now uncharted territory but there was still an awfully long way to go, with Djokovic having demonstrated his ability to come back from seemingly impossible positions many times in the last two years.
Murray also has a tendency to dip at the start of third sets and, although he got out of jail in the first game, in the third he could not prevent Djokovic breaking through.
The Scot had his chance to hit back in the sixth game but Djokovic saved two break points, roaring himself on.
Murray, too, was shouting at himself and he gave an insight into his mental state by revealing his legs felt like jelly, and a poor game allowed the Serb to take a 5-2 lead, which he quickly converted into the set.
Murray badly needed a good start to the fourth set but he did not get it, the Scot's forehand beginning to regularly find the net as Djokovic broke through again.
At least Murray saved a break point to prevent his opponent taking a 3-0 lead, but he was beginning to look rather disconsolate.
He showed more aggression in the next game to force a break point but Djokovic, fired up by a code violation for taking too long before serving, held on.
Murray was playing well again, though, and had Djokovic literally on his backside in one astonishing point in the sixth game.
Still the break back would not come, Djokovic serving better than he had at any point all evening, and as the match entered its fifth hour the Serb had his first set point on the Murray serve, taking it when his opponent fired a backhand long.
No one had come back from two sets down to win the US Open since Pancho Gonzalez in 1949 but Djokovic had both momentum and experience on his side.
However, there was a twist at the start of the decider when Murray got a bit of luck with a net cord and a potentially crucial break.
The 25-year-old then showed defensive skills worthy of his opponent to hold for 2-0, whipping up the crowd into a frenzy.
Suddenly Djokovic looked weary and Murray was half way there when the Serb netted a simple forehand to hand his opponent a second straight break.
He had, of course, been in a similar position in the second set only for Djokovic to hit back, and it was déjà vu as the Serb pulled one break back straight away.
It was torture for both players' supporters, but some brilliant serving from Murray gave him breathing space, and then suddenly he was a game away.
Djokovic made his opponent wait for the biggest service game of his life as he received treatment to his right thigh, drawing boos from the crowd who clearly felt it was unsporting.
But Murray gave the best response, setting up three championship points and taking the second when Djokovic drilled a forehand long.
After four hours and 54 minutes, the joint longest US Open final in history, Murray had done it, sinking to his knees in delight, disbelief and sheer exhaustion as his family and friends hugged each other and cried. Even Lendl smiled, just about.
Follow us @SprtNationalUAE