Ten-man Brazil leave it late to beat Mexico
Defender Daniel Alves was sent off just before half-time after his foul on Javier Hernandez in the box earned him a second yellow card.
However, Mexico failed to add to their early lead after an own goal by defender David Luiz with Jefferson saving Andres Guardado's penalty.
Ronaldinho equalised when he found the top corner with a shot in the 79th minute and defender Marcelo hit the winner five minutes later after a one-two with Neymar.
It was Mexico's first defeat in 15 matches under coach Jose Manuel de la Torre, though their under-23 side lost three matches at the Copa America in July under assistant coach Luis Fernando Tena.
There was a massive police presence at the match after a shooting incident outside the ground at a league match in August.