Javier Hernandez came off the bench to help Mexico reach the last 16 of the World Cup as their watertight defence and swift counter attacks gave them a 3-1 win against Croatia to emerge from Group A as runners-up behind Brazil.
Mexico will face Group B winners Netherlands in Fortaleza and had looked happy to hold out for the draw that would have seen them into the knockout stages, before the Manchester United forward came on to turn the match on its head.
Within 10 minutes of Hernandez entering, Rafael Marquez put Mexico ahead with a powerful header, before Andres Guardado rounded off a swift counter attack and Hernandez himself finished with a close-range header.
Mexico briefly flirted with top spot in the group, needing one more goal to depose Brazil before the tournament hosts got a fourth against Cameroon.
Ivan Perisic then grabbed a late consolation for Croatia who had substitute Ante Rebic sent off in the dying stages for a studs up challenge.