Peralta struck after just 30 seconds and the Mexican striker sealed one of the all-time great Olympic upsets when he scored again late in the second half.
Hulk got one back in stoppage-time but Mexico, playing in their first Olympic final, were deserved winners as Brazil once again failed to end their long wait for a first football gold.
Brazil, bronze medallists in Beijing in 2008, lost in the Olympic final in 1984 and 1988 and their failure to win gold has rankled with such a proud football nation for decades.
Photos: 'Dangal' girls Sanya Malhotra, Fatima Sana Shaikh's dinner outing
Photos: Salman Khan, Daisy Shah spotted at the Mumbai airport
Photos: Rakhi Sawant to play Honeypreet in Ram Rahim biopic
Photos: Arvind Kejriwal asks Kamal Haasan to join politics
Photos: TV actress who played goddesses on the small screen