Neymar lit up the occasion with an outstanding volley nine minutes in, but what threatened to be a goal glut for the hosts progressed in somewhat anticlimatic fashion, until the Barcelona forward brilliantly set up Jo for the clincher in the dying seconds.
Brazil's victory sees them move on to six points from two matches in Group A, and should Japan fail to defeat Italy in Wednesday's later match, their qualification for the last four will be guaranteed, a result which will also see Mexico eliminated.
Luiz Felipe Scolari named an unchanged XI from the side that dismantled Japan 3-0 on the opening matchday, while for Mexico, Javier Aquino and Jose Zavala were dropped for Hiram Mier and Gerardo Flores.
The hosts, fuelled by a raucous atmosphere inside the Castelao, made an electric start to the game, and Marcelo fired an early warning shot with an effort from a short free-kick that was well saved by Jose de Jesus Corona.
And though Flores stung the palms of Julio Cesar shortly after at the other end, there was only one side likely to profit from all the early momentum, and with nine minutes gone, Brazil duly delivered in sensational fashion.
Dani Alves scampered down the right and delivered into the box, but the Mexico defence could not clear any further than Neymar, just inside the area, who rifled a stunning volley into the corner.
Carlos Salcido attempted to respond for the visitors with a long-range attempt that flashed wide, but it was Alves’ subsequent effort that got the crowd off their feet, the right-back’s cheeky clip just missing the top corner thanks to Corona’s fingertips.
But despite Brazil’s dominance, there were signs of shakiness at the back, and when Marcelo gave the ball away a quarter of an hour in, determination from Mier forced play back into the box, where he drilled agonizingly wide of the far post.
Not long after, Neymar nearly struck again in equally brilliant fashion after holding off his marker at the top of the box and unleashing a piledriver that whistled inches over the crossbar.
However, as the first half neared its’ end, it Mexico began to wrest themselves back onto a more even footing, and caused a few tense moments in the Brazil ranks when working the ball into the box.
Not long after the restart, Thiago Silva had a header from Neymar’s free-kick ruled out for offside, before a scintillating Brazil move saw Fred play in Hulk who, from point blank range, missed the target completely.
Neymar, to his credit, was doing everything in his power to extend his side’s lead, first lashing inches wide from 18 yards out, before nearly fooling Corona by angling towards his near post, but the keeper managed to make the save.
The atmosphere inside the ground, once frenzied, was becoming ever more tenser as the second half wore on, with Brazil still holding onto their precarious advantage.
Paulinho came mightily close to putting the supporters' fears at ease with six minutes to go, blasting over the bar from close range after another fine piece of skill by Neymar to set him up in a great position.
But in the end, the fans needn't have worried, as Mexico failed to muster any serious challenge to Julio Cesar in goal before, deep into stoppage time, Neymar bamboozled a pair of defenders to square to Jo to fire home the clinching goal.