A star-studded gold medal match between Brazil and Spain saw the Brazilians pull through in extra time at Nissan Stadium in Yokohama on Saturday.
Brazil's medal comes on the same pitch that it won the 2002 World Cup, though this time around, it took an extra thirty minutes.
Matheus Cunha gave Brazil a late first-half lead but Mikel Oyarzabal had a second-half answer.
Malcom scored the winner for the South Americans midway through extra time when he received a pass from Antony, stormed into the penalty area, and took a shot that deflected off Spanish keeper Unai Simon but still found its way to the back of the net.
Cunha's late first-half goal off a Dani Alves assist made amends for Richarlison's missed penalty to give Brazil the lead at the break.
Ex-Barcelona man Alves beat ex-Barcelona man Marc Cucurella to the back post, and popped the toward the penalty spot. Hertha Berlin star Cunha kept his cool in traffic to unleash a clinical finish inside the near post.
Video Assistant Referee had intervened to award Brazil the penalty for Spain goalkeeper Unai Simon's airborne collision with Cunha, but Richarlison's stuttering run-up led to a shot blazed over the crossbar.
Richarlison would later smash the ball off the underside of the bar only to see bound away from goal.
Spain's answer arrived at the hour mark when Carlos Soler swept a ball to the back post and a sliding Oyarzabal snapped a left-footed shot into the goal, a Valencia to Real Sociedad connection leveling the score.
Spain hit the bar twice in the second half's latter stages, Bryan Gil smashing it in the 88th minute.
After an empty first half of extra time, the breakthrough came in the 108th minute through Malcom, who received a feed from Antony and calmly finished into the bottom right. Simon came out of his goal and got a foot on it, but it wasn't strong enough to parry the shot away.
Also winners at Rio 2016, Brazil become the fifth nation in men's Olympic soccer history to defend a gold medal.
In the bronze medal match, Mexico defeated Japan 3-1.
Will Fowler contributed to this report.