The Swiss world number one defeated Serbian Novak Djokovic 7-6 (7/4), 7-6 (7/2), 6-4.
The 26 year-old has matched Roy Emerson for second on the career Slam title list behind Sampras, surpassing 11-time Slam winners Bjorn Borg and Rod Laver and moving closer to beating Sampras — a goal that more and more occupies his mind.
"I think about it a lot now," Federer said. "To come so close already at my age is so fantastic and I really hope to break it. Don't know (how many). I hope more than Pete."
Shaking off a case of nerves, Federer took advantage of his record 10th Slam final in a row to improve to 12-2 in Slam finals, winning three Slams in a year for the third time in four years, losing only the 2006 and 2007 French Opens.
"It's just hard. It really works you," Federer said of the pressure of a Slam final. "You're like. 'I hope I didn't come all this way to lose.' In the end to win is happiness, relief, all together, it's the best feeling."
Third seed Djokovic netted a backhand volley to surrender the only break of the last set on Federer's second match point, ending the fight after two hours 26 minutes, his last of 40 unforced errors handing Federer a 51st career title.
"Straight sets is a bit brutal for Novak to be honest. He deserved better than that," Federer said. "I told him at the net, 'Keep it up.' He's going to have many more battles like that."
Federer won his fifth Wimbledon in a row in July, six months after taking his third Australian Open in four years, and stretched his US Open title streak to the longest since Bill Tilden won six in a row from 1920 to 1925.
Together with Justine Henin's victory in Saturday's women's final, it marked the first time since 1996 that both US Open singles titles went to top seeds.
The last time Federer lost a US Open match was a fourth-round defeat in the 2003 US Open at the hands of Argentina's David Nalbandian – a run that eclipses the old 27-match US Open Open-era record run of Ivan Lendl from 1985 to 1988.
Djokovic, 20, was undone by his mental mistakes on critical points in his first Grand Slam final.
"I had a lot of chances and I didn't use them," Djokovic said. "He knows how to cope with the pressure. For me this is a new situation. Next time I hope I don't falter."
The Serbian star, who suffered semi-final losses to Rafael Nadal this year at Wimbledon and the French Open, was only 2-of-9 in break-point chances, missing opportunity after opportunity and ultimately unable to stop Federer.
"Roger showed again he is the best. He deserved to win," Djokovic said.