Barbosa was sent off seconds before the final whistle after a fracas that followed a red card for River’s Exequiel Palacios.
The result gave Flamengo only their second Libertadores triumph and secured their berth as the South American confederation’s representative in December’s Club World Cup in Qatar.
“What a historic game,” defender Rodrigo Caio was quoted as saying on the Globoesporte website.
“We never gave up at any point. We knew it would be difficult against a big team, the 2018 champions… We’re delighted to make history with this club, with this magical victory.
“We hope it’s just the beginning.”
The Rio de Janeiro side came into the match as slight favourites on the back of a spectacular 26-game unbeaten run.
But playing in their first Libertadores final since 1981, they appeared overawed and River Plate seldom looked in trouble.
However, just when the match looked over, Barbosa popped up to sidefoot home a close-range equaliser and the 23-year-old striker pounced again in added time to hit the winner and send the Brazilian fans wild with joy.
The final in Lima was the first to be played on a one-off basis at a neutral venue in the competition’s 60-year history.
The match had originally been scheduled to take place in Santiago but was switched to Lima earlier this month because of political unrest in the Chilean capital.