Two goals from midfielder Carli Lloyd, a header after eight minutes and a rasping shot from the edge of the box in the 54th, set the US on their way to a fourth Olympic gold from the five women's tournaments played.
Japan, who beat the US on penalties in last year's World Cup final, halved the deficit after 63 minutes when the Americans failed to clear their lines, and Yuki Ogimi scored from close range, her third goal in successive matches.
Japan dominated in attack from then on but could not find an equaliser and were denied what looked like a certain goal seven minutes from time when US goalkeeper Hope Solo made an excellent save from substitute Mana Iwabuchi.
The attendance of 80,203 was a record for a women's match at an Olympics beating the 76,481 at the Atlanta Games in 1996.
It was also the biggest crowd to watch a women's football match in Britain beating the 70,584 that saw Britain play Brazil at Wembley earlier in the tournament.
They created a magical atmosphere at Wembley, completely different from the usual domestic crowds, with fans cheering and applauding both teams.
Although the US deserved their win, they rode their luck during the first half when Japan hit the bar twice and had what looked like a legitimate penalty appeal turned down.
After Lloyd gave the US an early lead, when she dived in to head the ball home just as Abby Wambach was shaping up to shoot, Ogimi should have equalised but was denied when Solo palmed her header on to the bar after 18 minutes.
Six minutes later the US, for the second successive match, benefited from a dubious refereeing decision in the box.
A well-struck free-kick clearly hit Tobin Heath on the left arm but, instead of awarding Japan a penalty, German referee Bibiana Steinhaus waved play on.
The US had benefited from being given a penalty in their semi-final when the ball struck a Canada defender's arm as she was turning away and the referee ruled in the US's favour.
Their next piece of luck followed in the 33rd minute when Shinobu Ohno rattled the bar with Solo well beaten.
Japan had their own slice of fortune before the break when Azusa Iwashimizu headed against the inside of her own post and saw the ball run across the face of goal before bouncing clear.
Japan, playing some neat passing moves, were never intimidated by the more expansive Americans and their perseverance paid off when Ogimi eventually forced the ball home after Solo and her defence failed to clear.
Earlier on Thursday, Canada beat France 1-0 in the bronze medal match at Coventry, with the players arriving at Wembley in time to watch the final and be presented with their medals on the pitch along with silver medallists Japan and the US.
The only discordant note of an unforgettable night came when Switzerland's FIFA president Sepp Blatter was booed by the crowd before the medal ceremony.
The head of football's world governing body is still unpopular with home fans for presiding over an organisation that awarded the 2018 World Cup finals to Russia instead of England.
- Related links