The match went on to extra-time and Portugal's Adrien Silva gave them the victor in the 104th minute.
Andre Silva had missed from the spot in the first half before Mexico claimed their fortuitous breakthrough and Juan Carlos Osorio's side looked set to end their campaign in Russian Federation in winning fashion before their late collapse. European champion Portugal was without captain Cristiano Ronaldo after the Real Madrid star was released from the squad to return home to meet his newborn twins.
Both teams ended the game at Spartak Stadium with 10 men as Portugal's Nelson Semedo was dismissed in the 106th and Mexico's Raul Jimenez six minutes later.
At least 2 shot at Bronx-Lebanon Hospital
A staff member at the hospital tells News 4 it was under lockdown as police helped to bring people out floor by floor. Emergency medical workers can not yet enter the building as it has not yet been secured by police.
Mexican goalkeeper Guillermo Ochoa saved Andre Silva's penalty early on but trailed to Luis Neto's own goal in the 54th minute. Rui Patricio produced a sharp stop to deny Javier Hernandez, Mexico's all-time leading scorer, from close range on the half hour, but the Portugal keeper was beaten shortly after the break.
Adrien Silva then scored from the spot in 14th minute of extra time to put his side in the driving seat and on the way to glory.