Journeyman Diego Tardelli was the unlikely hero with his first two goals for Brazil as Messi fluffed his lines with a tame spot-kick at the Bird’s Nest stadium.
Atletico Mineiro striker Tardelli, 29, put Brazil ahead on 28 minutes, before Messi curled his soft penalty attempt close to goalkeeper Jefferson just before half-time.
And Tardelli was on target again midway through the second half as Brazil restored pride after the World Cup, when the hosts were hammered in the semis while Argentina reached the final.
Argentina were on top early in the match and Sergio Aguero fired an inviting early chance over the bar before Angel Di Maria threatened with a drive from distance.
But it was Tardelli who broke the deadlock when he pounced on a loose ball and volleyed past Argentina goalkeeper Sergio Romero on 28 minutes.
Brazil superstar Neymar should have made it 2-0 shortly afterwards but after wriggling his way free on goal, he made a hash of his shot and the ball rolled harmlessly wide.
The game had come alive and Argentina got a golden chance to equalise when Danilo was judged to have fouled Di Maria in the box, prompting angry Brazilian players to surround Chinese referee Fan Qi.
Messi looked certain to bury the spot-kick but the four-time world player of the year shot too close to Brazilian ‘keeper Jefferson, who dived to his right for a simple stop.
It was the Barcelona icon’s second penalty miss in two weeks after he also missed one for his club last month against Levante.
Filipe Luis and Di Maria had chances at either end as the second half started energetically, and Oscar went close with a free kick after Martin Demichelis chopped down Neymar.
But again Tardelli was in the right place at the right time as he nodded in Oscar’s cross at the back post to give Brazil breathing space on 64 minutes.
Tardelli was eventually replaced by Kaka, who drew a huge roar when he came on in the final minutes to end a prolonged spell in the international wilderness.
And there was time for Neymar to twice go close before Brazil were able to celebrate their win in the 2008 Olympic stadium.
Fears over Beijing’s choking smog had dominated the build-up but in a relief to players and organisers, air quality and visibility lifted on a breezy day in the Chinese capital.