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 Scot had never beaten Federer in a best-of-five-sets match and lost to him in the Wimbledon final.
He is the first British man to win the Olympic singles gold medal since Josiah Ritchie in 1908.
Murray plays the mixed doubles final with Laura Robson later on Sunday.
The pair face Belarusian top seeds Victoria Azarenka and Max Mirnyi knowing they are guaranteed at least silver.
Team GB remain third in the London 2012 medal table, with Murray's triumph in just an hour and 56 minutes the 16th gold medal of a glorious Games for the host nation.
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 - and deservedly so.
Victorious over Djokovic in the semi-finals, he 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.