United defender Rafael was involved in surrendering possession in the opening minute, and his mistake was clinically punished as Oribe Peralta pounced on the loose ball and drilled home a low finish.
Clearly rocked, Brazil never recovered from their poor start to the afternoon, while Mexico revelled as both sides chased their first ever gold medal in Olympic football.
Fabian Marco's improvised overhead kick rebounded off the Brazil crossbar before Peralta firmly headed home his second of the game with 15 minutes remaining.
Rafael was substituted in the final five minutes, shortly before Hulk halved the arrears in injury-time. Chelsea recruit Oscar then spurned a clear chance to take the game to extra-time, but Mexico held on for a deserved victory.
Brazil's wait for Olympic gold continues, while Rafael will now report for pre-season training with United, providing welcome reinforcements amid Sir Alex Ferguson's ongoing defensive injury issues.