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.
While Brazil have graced the World Cup with some of the best players and most dazzling performances ever seen on football's grandest stage, the Selecao have never managed to replicate those golden moments at the Games and this was another miserable chapter in their Olympic history.
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.
Mano Menezes's team are unlikely to get a sympathetic reception on their return home after such a lacklustre display riddled with nerves and defensive blunders.
From Rio to Sao Paulo those unconvinced by Menezes had already begun to whisper that former Brazil coach Luis Felipe Scolari should be installed in time to lead the nation's bid to win the World Cup on home soil in 2014 and those calls will get even louder after Mexico's giant-killing act.
After sweeping to the final with five successive wins, Brazil were heavy favourites and Mexico's chances looked even slimmer when Tottenham striker Giovani dos Santos was ruled out with a hamstring injury suffered during the semi-final win over Japan.
But the Mexicans had won three of their past five matches against Brazil, including a 2-0 friendly victory in June, and there was no sign of an inferiority complex as Luis Fernando Tena's side made an astonishing start.
Just 30-seconds had been played when Manchester United right-back Rafael da Silva dwelt on the ball and then poked a hesitant pass towards Sandro, who was caught flat-footed as Javier Aquino stole possession.
Peralta latched onto Aquino's pass and the Santos Laguna striker advanced unchecked before slipping a clever low shot past Brazil goalkeeper Gabriel from just outside the penalty area.
Brazil seemed shell-shocked by such a disastrous opening. It took 21-minutes for Brazil's first shot on target and Menezes was growing increasingly frustrated on the touchline.
By the 32nd minute he had seen enough and hauled off Alex Sandro, with Porto striker Hulk sent on.
That at least gave Brazil a brief spark and defender Marcelo slashed wide after Oscar's flick gave him a sight of goal, then Hulk surged forward and forced Jose Corona to parry his long-range strike.
Leandro Damiao was quickly onto the rebound, but Corona recovered his footing to block the striker's follow-up.
Brazil needed more from Neymar in the second half but the Santos striker's composure deserted him when he lashed a good chance high over the bar.
Marco Fabian should have made Neymar pay for that miss when the Mexico midfielder harried Juan Jesus out of possession. But Gabriel blocked Fabian's first shot and from the rebound the Mexican's overhead kick looped onto the crossbar.
Moments later Peralta saw his shot ruled out for offside, but Brazil's defensive frailties were exposed again in the 75th minute.
When a free-kick was curled over from the right, Peralta was granted the freedom of the penalty area to power home a header that left Brazil exchanging angry recriminations.
Hulk gave them hope of a dramatic late fight-back when he burst through to drive a low shot under Corona in the first minute of stoppage-time.
And incredibly Oscar should have forced extra-time, but the Chelsea midfielder headed over with the goal at his mercy as Mexico held on. – AFP.