Neymar scored the winning penalty as hosts Brazil beat Germany 5-4 on penalties in Rio to win their first men’s Olympic football gold medal.
The game finished 1-1 after extra time, with Neymar’s first-half free-kick cancelled out by Max Meyer’s strike.
In the shootout, Germany’s Nils Petersen had his penalty saved by Weverton before Neymar won it.
It comes two years after Germany thrashed Brazil 7-1 in the 2014 World Cup semi-finals in Belo Horizonte.
In front of 78,000 at the Maracana, Brazil got a measure of revenge as they finally won the Olympic title after losing in the finals in 1984, 1988 and 2012.
Barcelona forward Neymar, who missed the World Cup semi-final through injury, opened the scoring with a fine 25-yard free-kick, but the hosts were lucky to go in at half-time with the lead.
Germany hit the woodwork three times in the first half – through Julian Brandt’s 25-yard effort, a deflection off a Brazilian defender and Sven Bender’s header – before they scored a deserved equaliser shortly after the restart.
Bender passed to the overlapping Jeremy Toljan and he found the unmarked Meyer, who arrowed a low shot into the net.
Neither side could find a winner before the drama of the penalty shootout gave Brazil the gold.
Goalkeeper Weverton said: “The gold is ours, but it belongs to God. God loves Neymar like he loves all this team.”
Neymar added: “This is one of the best things that has happened in my life. That’s it.”