The world No 1 won 6-4 5-7 6-4 6-4 in New York, and will end the year with three of the four tennis majors.
Novak Djokovic, 28, held his nerve in front of a heavily pro-Federer crowd at Flushing Meadows.
Roger Federer, 34, had been hoping to win his 18th major title and first for three years.
In a raucous night session on Arthur Ashe Stadium, after the start of play was delayed by more than three hours because of rain, the Swiss looked to have a real chance in the third set.
However, Novak Djokovic broke the Federer serve six times and saved 19 of 23 break points as he battled his way to a 27th win in 28 Grand Slam matches this year.
Novak Djokovic took another step towards joining the very best in history with a 10th major title, moving him within one of Bjorn Borg and Rod Laver in the all-time list.
Defeat by Stan Wawrinka in the French Open final in June means Novak Djokovic was just one win short of completing the first calendar Grand Slam in men’s tennis since Laver in 1969.
“It’s been an incredible season, next to 2011 the best of my life,” said Novak Djokovic.
He won three Grand Slam titles four years ago.
“I’m enjoying this year more than I did any previous one because I’m a husband and a father, and that makes it sweeter.”
Five-time champion Roger Federer was playing his first US Open final since 2009, and drew one of the loudest cheers of the night when he told the crowd: “I’ll see you guys next year.”
Roger Federer said it was “always tough” facing Novak Djokovic, adding: “I think we both walk away from it knowing more about our games and more about each other.
“I’m pleased with where my game is at.”
Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…