Portugal defeated Mexico, 2-1 in the third place game of the 2017 FIFA Confederations Cup in Moscow.
Adrien Silva netted an extra-time goal from the spot as the European champions came from a goal down after Luis Neto had scored an own goal.
Real Madrid star, Pepe, then bagged a stoppage-time equaliser to push the match into an extra 30 minutes at Spartak Stadium.
Silva then scored his maiden international goal after a handball inside the box on 104 minutes.
Both teams finished with 10 men as Nelson Semedo was sent-off for Portugal before Raul Jimenez saw red for Mexico.
Later in the day, World champions, Germany will tackle Copa America winners, Chile in the final in Saint Petersburg.