Brazil midfielder Lucas was sent off in the 81st minute after a foul from behind on Liverpool teammate Javier Mascherano. And substitute Thiago Neves was red-carded three minutes later after another hard foul on Mascherano. Argentina, attempting to become the first nation to win consecutive Olympic football titles in 40 years, now face Nigeria in a rematch of the 1996 final in Atlanta where the Africans triumphed 3-2.
Nigeria beat Belgium 4-1 in their semifinal in Shanghai where Chinedu Ogbuke Obasi scored two goals and Olubayo Adefemi and Chibuzor Okonkwo added one each.
Aguero opened the scoring for defending champions Argentina by chesting in a left-side cross in the 52nd minute, then scored again from two meters on a cross from the right in the 58th.
Aguero also set up a 76th-minute penalty kick that was converted by Juan Roman Riquelme.
It was Argentina's first victory over Brazil since a 3-1 victory in a World Cup qualifier in June 2005.
"It's not a score you see every day when Brazil and Argentina play," Argentina coach Sergio Batista said. "Argentina had a great match, with intelligence and personality."
Brazil will have to wait at least another four years to claim their first Olympic soccer gold -- the only significant title the five-time world champions have never won.
The match in front of a crowd of nearly 53,000 at Workers' Stadium marked the encounter of the tournament's top stars, former FC Barcelona teammates Lionel Messi and Ronaldinho.
Both players displayed their uncanny skills, but Messi threatened the most and created dangerous scoring chances for Argentina.
In his first Olympics, the midfielder set up Argentina's second and third goals, while AC Milan's Ronaldinho struck the post with a free kick as he tried to put Brazil back into the match.
Messi sent a dangerous shot across the area in the 32nd, and had one of his best chances in the 41st after clearing three defenders inside the area before firing a shot that was barely saved by goalkeeper Renan.
Aguero ran past defender Breno to open the scoring after Angel di Maria's cross, then easily added to the lead in front of the goal mouth after Ezequiel Garay's set-up.
Messi started the play on the second goal by eluding several defenders before feeding the ball to Garay.
Messi also set up Aguero inside the area before he was fouled by Breno in the play that prompted the penalty kick, which Riquelme converted with a right-footed shot into the middle of the net.
After Aguero's first goal, striker Rafael Sobis almost equalized with a powerful low shot that struck the post in the 60th. Ronaldinho also hit the post on a free kick in the 65th. Substitute forward Alexandre Pato scored after the free kick, but the goal was disallowed for offside.
Brazil midfielder Lucas was sent off in the 81st after a foul from behind on Liverpool teammate Javier Mascherano. Substitute midfielder Thiago Neves was red-carded just three minutes later after another hard foul on Mascherano.
"It was Argentina's best match in the Olympics so far," Batista said. "It was a well-deserved result."