The reigning Olympic champions Argentina will meet Nigeria on Saturday in a repeat of the 1996 Olympic final after Atletico Madrid's Sergio Aguero put away two second-half chances here to end the hopes of their arch rivals.
Juan Riquelme also converted a 76th-minute penalty, and then Brazil's night ended in ignominy . Lucas was sent off after a foul from behind on his Liverpool team-mate Javier Mascherano and Fluminense's Thiago Neves was red-carded three minutes later after another hard foul on Mascherano.
Nigeria, who won gold 12 years ago with a team including Jay-Jay Okocha, Sunday Oliseh and Kanu, reached this year's final by beating Belgium 4-1.
While the atmosphere for the Argentina verses Brazil semi-final should have been epic, it was actually just a bit jolly. Almost 60,000 fans, mostly Chinese, packed the stadium but they were here for the stars, and if those stars happened not to be playing, then never mind.
Hence the biggest roar of the night was when a picture of Diego Maradona waving from his seat was shown on the big screen, and the largest craning of necks was for a glance of the USA basketball player, Kobe Bryant, who had come along to see what all the fuss over this Messi kid is all about.
Messi was the player most lauded by the supporters, appropriately in a first half when his running, jinks and tricks most threatened a goal. Except they didn't and clear-cut chances were rare. Ronaldinho knocked around a few Hollywood balls but with no real bite.
Argentina began the second half much the sharper, and were ahead in the 52nd minute when Aguero chested in a cross, and off into the distance when he tapped in from Mascherano.
Goals: Aguero (53, 58), Riquelme (76).
Sent off: Brazil Lucas, Neves.
Argentina (4-3-3): Romero; Zabaleta, Pareja, Garay, Monzon; Gago, Mascherano, Di Maria; Messi, Riquelme (Sosa), Aguero.
Brazil (4-2-3-1): Renan; Rafinha, Alex Silva, Breno, Marcelo; Lucas, Anderson; Hernanes (Neves), Diego (Jo), Ronaldinho; Rafael Sobis (Pato).
Referee: M Vasquez (Uruguay).