Mexico reached the World Cup last 16 with a near-perfect display of counter-attacking football as Javier Hernandez provided the spark for a 3-1 win over Croatia on Monday that left them as Group A runners-up.
Mexico, who will face the Netherlands in the last 16, had looked happy to hold out for the draw that would have put them into the knockout stages before the Manchester United forward came off the bench to turn the match on its head.
Within 10 minutes of Hernandez entering the fray in the second half, Rafael Marquez put Mexico ahead with a powerful header, Andres Guardado rounded off a swift counter-attack and Hernandez himself struck with a close-range header.
It was the striker's first international goal since last year's Confederations Cup and capped an all-round performance in which his energy, clever movement and precise hold-up play proved the difference in a previously cagey clash.
"We needed someone who would revolutionize (our game)," Mexico's jubilant coach Miguel Herrera told reporters.
"Javier did a very good job, he came in held the ball and did very well and even got a goal which was great...
"We know he gives everything and we are very happy with his attitude today and all the time."
Mexico, securing a sixth successive appearance in the second round, finished second in the group with seven points, behind Brazil on goal difference after the hosts beat Cameroon 4-1.
They briefly flirted with top spot, needing one more goal to depose Brazil before the tournament hosts got a fourth against their African opponents.
Croatia, who began the match chasing a victory that would have sent them through, grabbed a late consolation through Ivan Perisic before substitute Ante Rebic was sent off in the dying stages for a studs-up challenge.
Having been bullish in the lead-up to the match, Croatia boss Niko Kovac was generous in defeat, pointing the finger of blame for their second-half capitulation down to a formation change intended to help them chase the game.
"We tried to turn the situation around," he said of his decision to revert to their more common 4-2-3-1 set-up.
"When we conceded the first goal, it meant we had to score two, we were wide open and they finished us off on the break."
With only one team needing to win, it was perhaps inevitable that Mexico would adopt a no-risk strategy that involved keeping sufficient numbers behind the ball and inviting Croatia to press in the hope of hitting them on the counter.
With the Pernambuco arena jam-packed with green-clad fans with reams of novelty sombreros dotted among the stands, an ear-splitting noise greeted every Mexican foray into the Croatia half.
Having not conceded against Brazil and Cameroon in their previous two games, Mexico's backline restricted Croatia to a handful of half-chances in the opening 45 minutes, with Perisic slicing their best effort wide from the edge of the box.
Mexico's Hector Herrera rattled the crossbar with a vicious left-foot drive from distance after 15 minutes but the second half was almost entirely controlled by the men in green.
Having had two goals harshly disallowed in their opening game against Cameroon, Mexico seemed to be on the receiving end of another piece of poor officiating as they had a strong penalty appeal turned down 20 minutes into the second half.
Guardado's shot was clearly handled by Croatia captain Darijo Srna, leaving the Mexico players to rage against referee Ravshan Irmatov as plastic cups rained down onto the pitch from angry fans.
The ire turned to elation, however, as they took the lead with 18 minutes to play.
With Hernandez exploiting the wide-open spaces left as Croatia pushed forward, Mexico started to get on top and it was captain Marquez who put them ahead, rising powerfully in the area to head a set-piece from the left into the bottom corner.
Three minutes later and the Mexican crowd were rocking in the aisles as Guardado arrived unmarked at the far post and finished off a sweeping counter-attack with a crisp finish past Croatia keeper Stipe Pletikosa.
Hernandez rounded off the scoring, heading a Marquez flick-on from a corner into an unguarded goal with eight minutes left.