The Swiss third seed recovered from a sluggish start to dominate the match and return to the top of the world rankings, ending Murray's hopes of becoming the first British man to win the title on home soil for 76 years.
After sharing the first two sets, rain halted the contest for 40 minutes early in the third and when the players returned under the closed roof on Centre Court Federer took control.
He made the decisive break in a marathon sixth game and broke again for 3-2 in the fourth set before sealing victory on his second match point in three hours 24 minutes.
"I played some of my best tennis in my last couple of matches," Federer told the crowd after lifting the trophy.
"I couldn't be more happy. It feels being great being back here as the winner and it's a great moment. It feels nice to have this trophy back after three years," he added.
An emotional Murray struggled to hold himself together when he took the microphone after his first Wimbledon final.
"I am getting closer," Murray, who had twice lost to Federer in straight sets in Grand Slam finals, tearfully told the crowd.
"I'd like to congratulate Roger. He played a great tournament and he's not bad for a 30-year-old," he added.
Murray broke Federer's serve in the opening game of the match but the Swiss immediately broke back to level at 2-2.
Federer mixed up his game to increase the pressure on Murray but the fourth seed dug in and conjured up his second service break in the ninth game before serving out to seal the first set in just under an hour.
The second set went with serve and Murray generally held the upper hand but Federer suddenly found some magic in the 12th game and broke his opponent with a sublime drop volley to level the match.
Rain halted play at 1-1 in the third set and it resumed under the closed roof.
Playing aggressively Federer began to dominate the rallies and the set hinged on the sixth game in which Murray slipped over three times and Federer converted his sixth break point to open up a 4-2 lead.
The Swiss, peppering the lines with his groundstrokes, clinched the set with an ace to move within touching distance of the title.
Murray tried desperately to cling on at the start of the fourth set but Federer sensed his chance, breaking serve with a brilliant dipping crosscourt backhand winner to lead 3-2.
Federer, in ruthless mood, was not going to miss his opportunity and after netting his first match point he secured victory when Murray sent a forehand narrowly wide.
Photograph: Julian Finney/Getty Images