Shrugging off a three-hour rain delay and the overwhelming hostility of the Arthur Ashe Stadium crowd, the 28-year-old world number one captured his second title in New York to add to his 2011 triumph.
The defeat shattered 34-year-old Federer's bid to become the oldest US Open champion in 45 years and left him marooned on 17 Grand Slam titles, the last of which came at Wimbledon in 2012.
Djokovic added the US Open title to his Australian Open and Wimbledon victories this year.
Had it not been for a heartbreaking loss to Stan Wawrinka in the French Open final in June, the rock-solid Serb would have been celebrating a rare calendar Grand Slam.
Djokovic's 10 majors takes him level with American Bill Tilden and just one shy of Bjorn Borg and Rod Laver on the all-time list.
Federer was ultimately undone by 54 unforced errors and his ability to convert just four of 23 break points.
“I have tremendous respect for Roger and the challenge he presents,” said Djokovic, who is now 21-21 in career meetings with Federer.
“He's the best player ever. I knew I needed to play my best in order to win. It's an incredible evening.”
He added: “I love this sport and all these achievements are incentive for me to keep on going.”
Federer insisted he would be back to try again in 2016.
“I love tennis. I'll see you back here next year,” said the veteran.
“I'm pleased with where my game is, but playing a great champion like Novak is always difficult.”
With the likes of Robert Redford, Sean Connery and David Beckham watching, and with Eva Asderaki-Moore making history as the first woman to umpire the men's singles final, Djokovic was dialled in from the start despite heavy rain forcing a three-hour delay and an evening start.
He forced five-time champion Federer, playing in his first US Open final in six years, to save three break points in a six-minute opening game.
The top seed held to love and then broke for 2-1 — just the third time in 84 service games at the tournament that the Swiss veteran had been broken.
Bloodied but unbowed
However, with the playing surface still damp from the hours of rain, the Serb suffered a worrying fall in the next game, turning over on his right ankle and bloodying his elbow.
Federer pounced to retrieve the break but the Serb was soon back in the ascendancy and Federer was broken again in the seventh game.
Federer saved a set point in the ninth, but conceded the first set with a netted backhand in the 10th game.
It ended his run of 28 consecutive sets won, a mark stretching back to July's Wimbledon championship match, where he lost to Djokovic.
Djokovic saved five break points in an eight-minute game to go 1-1 in the second set despite Federer's first use of his 'SABR' charge-and-chip ploy.
Federer then had two set points in the 10th game — surrendering one with a wild forehand with an open court at his mercy.
Djokovic held after seven deuces and 15 minutes of unbearable tension as he faced down Federer and the majority of the crowd.
The Swiss allowed another set point to slip away in the 12th game but he converted his fourth on a monster backhand to level the final.
The stadium erupted, leaving no doubt whatsoever as to the crowd's affections.
Djokovic broke for 2-1 in the third, but unsettled by a call from the crowd during his service action he handed back the break for 2-2.
The top seed saved two break points in the eighth game before Federer suddenly lost focus and out of nowhere handed Djokovic a 5-4 lead.
Federer had two break points as he desperately clung on but Djokovic held his nerve to serve it out.
Djokovic sensed blood and broke in the opening game of the fourth set and saved a break point to lead 4-2.
The Serb broke again for 5-2, roaring at the crowd and the New York nighttime sky.
But there was still time for a twist as Federer retrieved one of the breaks when Djokovic served for the title and backed it up with a hold.
The Swiss let three more break points slip away in the 10th game before nerveless Djokovic sealed victory off a long Federer service return.
Speaking afterwards, Federer said he believes he can still punch his weight at the highest level, with his five tour titles so far in 2015 only serving to boost his confidence.
“I am very disappointed. I had my chances on my racquet. I should never been down in the score the way I was,” said the Swiss.
“But Novak did a great job of fending them off. It was a tough night.”
“I am playing a good year. I'm playing good tennis. I am happy with where my level is at. I'm able to beat the best players regularly.”
Swiss star Martina Hingis had a happier outcome of her women's doubles final, clinching a 6-3 6-3 victory with Indian partner Sania Mirza over Yaroslava Shvedova and Casey Dellacqua.
Hingis, 34, had also won the mixed doubles title alongside Leander Paes.
The latest win means the Swiss player has now claimed five major doubles titles in total in 2015, and 14 Grand Slam doubles titles in her career to date.