Updated

Brazil's trophy case is finally complete.

The five-time World Cup champion won the only championship it was still missing on Saturday, defeating Germany 5-4 in a penalty shootout and winning a soccer gold medal for the first time.

Neymar scored with a superb free kick in regulation and converted the decisive penalty in the shootout after Brazilian goalkeeper Weverton stopped Nils Petersen's shot.

It was the crowning achievement of the 2016 Olympics for Brazil, restoring some of the nation's soccer pride after a series of disappointing results. Neymar fell to the field sobbing after he was mobbed by his teammates as the crowd at iconic Maracana Stadium roared.

The victory avenges the embarrassing 7-1 home loss to Germany's senior team in the World Cup semifinals two years ago. Brazil was also coming off a demoralizing elimination in the group stage of this year's Copa America.

Germany, playing with a young team that looked nothing like the World Cup-winning squad, made it hard for Brazil, hitting crossbar three times in the first half and sending the game into extra time after a 59th minute equalizer by captain Maximilian Meyer.

Germany hadn't played in the Olympic tournament since 1988, when Jurgen Klinsmann was on the team and it won the bronze. The senior team defeated Argentina in the World Cup final at the Maracana.

The men's soccer tournament attracted most of the attention of Brazilian fans at the Olympics. The Brazilian football federation took the Olympic tournament as seriously as ever, bringing Neymar and many talented youngsters that are expected to be in the main squad in the 2018 World Cup in Russia.

Brazil had lost three Olympic finals, including four years ago in London, when it was upset by Mexico 2-1 with a team that also included Neymar and other talented players. Brazil won the bronze two times.

Neymar, who skipped the Copa America to try to give the hosts the Olympic gold, avoided joining a long list stars who failed to win the gold for Brazil, including Romario, Rivaldo, Ronaldo and Ronaldinho.