Twelve minutes later, captain Andreas Granqvist kept his concentration in the face of deafening boos and whistles from the Mexican fans to blast a penalty into the top left corner after Hector Moreno had brought down Marcus Berg.
Twelve minutes later it was 3-0 as Alvarez scored a calamitous own goal when he sliced the ball onto his standing leg from six yards and it bounced beyond Ochoa.
"I'm so incredibly proud, moved nearly, by the thought of how we performed in the match".
Mexico, undone on the counter attack and from the penalty spot before conceding an own goal, joined Sweden in reaching the next round as runners-up despite the defeat after the defending champions also lost.
He called qualification "bittersweet" and made clear his disdain for what he perceived to be Sweden's long-ball approach.
Berg posed repeated problems for the Mexican defence, first flicking wide with his back to goal, and later firing a well-struck shot that was acrobatically turned over the bar by goalkeeper Guillermo Ochoa. This victory locks the first place in the group for Sweden, as they qualify for the second round.
NIZHNY NOVGOROD, Russia - Switzerland is through to a knockout game against Sweden at the World Cup.
The four-time champions allowed a pair of injury-time goals while knowing a 1-0 victory would have been enough to advance because of the result in the other group match. "That match made us stronger, more confident".
El Tri's faithful could be seen frantically checking their phones for scoring updates in Germany's game soon after Sweden's second goal.
"We are courageous enough not only to dream, but to work on those dreams so that we can make them true", Hernandez said. "Let's hope the height of the players will play a part because we're good in those situations", Andersson said, adding that he may not make too many changes to the team that started the last match. Mexico will play winners of that group in Samara on Monday afternoon.
Mexico's Javier Hernandez strikes a shot. "We haven't forgotten hearing the boos at the Azteca, and that has strengthened us mentally", Ochoa said.
They gave the formidable Germans a tough time before Jimmy Durmaz conceded the foul that allowed Toni Kroos to score a dramatic late victor for the defending champions.