In the 54th minute of the match, Portugal's Luis Neto scored an own goal putting Mexico ahead.
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.
Tour de France 2017
I'm going to have to make sure I'm absolutely at my best and to take advantage of any situations out on the road. He's been with the team a long time now and has a lot of experience.
Both teams ended the match with 10 players after Nelsinho and Raul Jimenez were both given their marching orders.
In extra time, Miguel Layun gave Portugal a golden opportunity to take the lead with a senseless handball inside his own penalty box.
Portugal should have gone in front in the drizzling rain on 17 minutes when Andre Silva was upended by 38-year-old Rafael Marquez, with the video assistant referee stepping in to award the spot-kick. In the previous matches between Portugal and Mexico, Portugal won two matches and another match end in a draw.