The Olympic gold is the only significant trophy that Brazil, five-time world champions, hasn't won in soccer. The Brazilians established the London Games as the team's priority this year and arrived as the heavy favorite after bringing most of its top players for the competition. Many will also be in the team for the next World Cup, which will be played in Brazil.
"We're very sorry yet again not to get gold," Menezes said. "Defeat is part of the maturing process. This group will continue on this path and get ready for 2014."
Fans threw straw sombreros in the air and waved Mexican flags at the final whistle. Peralta got hold of one of the wide-brim hats and passed it around among his teammates.
As Mexican players jumped up and down at midfield in celebration, the Brazilians dropped to the ground in despair. Neymar, touted as the future of Brazilian football, was one of them, sitting stoned-faced. Real Madrid left back Marcelo dropped his head and cried as his teammates came to try to console him.
The Mexicans started celebrating early in front of a crowd of more than 86,000.
Peralta's goal came after Manchester United right back Rafael tried to make a pass backward. Mexican midfielder Javier Aquino intercepted the ball, sending it forward to Peralta just outside the area. With no defenders near him, he calmly fired his shot just inside the near post.