“It's number one for me - the biggest win of my life”
Murray beat the Swiss world number one in straight sets, 6-2 6-1 6-4, on a raucous Centre Court.
The 25-year-old is the first British man to win the Olympic singles gold medal since Josiah Ritchie in 1908.
He had never beaten Federer in a best-of-five-sets match and lost to him in this year's Wimbledon final.
Murray's triumph came four weeks to the day since that 6-4 5-7 3-6 4-6 loss to Federer at the All England Club.
Murray later faced a second Olympic final in a day, but he and mixed doubles partner Laura Robson could not overcome Belarusian top seeds Victoria Azarenka and Max Mirnyi. They lost 2-6 6-3 10-8 in a champions' tie-break decider and had to settle for silver.
Team GB remain third in the London 2012 medal table, with Murray's singles triumph in just an hour and 56 minutes the 16th gold medal of a glorious Games for the host nation.
Afterwards he climbed into the stands to celebrate with his girlfriend, family and support team as Federer again missed out on the one accolade missing from his CV.
Murray then mounted the podium with Federer and bronze medallist Juan Martin del Potro of Argentina, who beat Serbia's Novak Djokovic 7-5 6-4 in an hour and 48 minutes earlier in the day.
There were no obvious tears, but it was clear how much this meant to Murray as he sang along to parts of the national anthem and then draped himself in a union jack.
Having suffered a shock first-round defeat by 77th-ranked Yen-Hsun Lu in Beijing four years ago, he will be delighted to have contributed this time round.
Murray becomes the first Briton to claim an Olympic men's singles medal since Charles Dixon took silver at the 1920 event in Antwerp.
Victorious over Djokovic in the semi-finals, Murray troubled an error-strewn Federer from the outset and broke serve in game six before holding for 5-2 with two booming aces.
Murray buried a backhand passing shot to wrap up the 37-minute first set but, given he also took the opener in the Wimbledon final, there remained a sense of caution around the stadium.
That caution turned into belief when a forehand pass clipped a net cord to elude Federer in game two of the second set and he then saved six break points to hold for 3-0.
Federer looked agitated and his fans dejected and a rare double fault let Murray strike again before the Scot swiftly served out to extend his advantage.
The Scot's performance continued to improve as his opponent's faded and Federer's delivery was breached decisively in game five of the third set as Murray powered towards the finishing line, dropping just one point on serve as he closed out with an ace.
"I didn't expect that at the start of the week," added Murray after collecting his gold medal. "I thought I'd go deep into the tournament but I felt so fresh today. It's amazing."