Mexico City: Ronaldinho and Marcelo were on target as 10-man Brazil came from behind to beat Mexico 2-1 in a friendly in the northern Mexican city of Torreon on Tuesday evening.
Mexico had taken a 10th-minute lead courtesy of a David Luiz own goal, before Dani Alves was shown a second yellow card after conceding a penalty shortly before the interval.
However, Brazil goalkeeper Jefferson saved Andres Guardado's attempt from 12 yards.
Ronaldinho then equalised for the 2014 World Cup hosts from a free-kick 11 minutes from time.
It was his first goal for the Selecao since 2007 and provided the platform for them to go on and win the game.
Real Madrid full-back Marcelo struck the winner for Mano Menezes' side in the 83rd minute after being set up by Neymar.
The win was Brazil's second in five days following a 1-0 victory against Costa Rica on Friday.
It was Mexico's first defeat under Jose Manuel de la Torre, who had previously overseen 10 wins and four draws since taking over in October last year.
The game also marked Mexico goalkeeper Oswaldo Sanchez's 100th and last appearance for the national team.