Chile substitute Martin Rodriguez scored his first international goal to salvage a 1-1 Confederations Cup draw with Australia that seals a mouth-watering semi-final tie against Portugal.
James Troisi scored his first Australia goal for over two years to give the Socceroos - who needed a two-goal victory to move above their opponents in Group B - a surprise half-time lead.
But Rodriguez, who was introduced at the break, levelled to calm Chile's nerves about elimination and ensure they finish second to pool winners Germany, who beat Cameroon 3-1 in Sunday's other game.
Chile came into the match in Moscow sitting top of the group, a position that would have seen them face Mexico, but instead they will meet Cristiano Ronaldo and the European champions in the last four.
Australia, meanwhile, are out and finish third in the group as their winless Confederations Cup run extends to six matches despite a creditable performance against the world's fourth-ranked side.
Chile made a fast start, Arturo Vidal meeting Jose Fuenzalida's cross and forcing Mathew Ryan to parry away his volley from the edge of the area, with Eduardo Vargas unable to convert the rebound.
Mark Milligan made a superb challenge on Alexis Sanchez as the Chile forward bore down on goal, VAR finding no issue, while Tim Cahill - who became the second Australia player to reach 100 caps - was booked for a rash foul on Charles Aranguiz, a decision backed up by another review.
Australia threatened for the first time when Massimo Luongo forced a good close-range save from Claudio Bravo after Troisi's throughball and the Socceroos then took a surprise lead after 42 minutes.
Chile lost possession after Bravo had tried to play the ball out from defence and Robbie Kruse overcame a challenge from Gonzalo Jara to divert the ball into the path of Troisi to dink a cool finish over the keeper from six yards.
After Vidal's header was deflected to safety at the other end, it should have been two for Australia before half-time, only for Trent Sainsbury to blaze over a volley with the goal gaping after Cahill had presented him with the opportunity.
Chile made a double half-time change, Pablo Hernandez and Rodriguez coming on and they made a decent start to the second half, Ryan reacting quickly to push away a powerful Vargas effort.
Brighton keeper Ryan kept out Sanchez, before Chile drew level in scrappy fashion with 23 minutes remaining.
Eugenio Mena's cross was only half cleared by Sainsbury, allowing Vargas' header to keep the ball alive and Rodriguez to force his effort past Ryan from six yards.
Chile squandered a great chance to complete the turnaround when Sanchez beat Milligan down the left and cut back for Vargas, whose header drifted just wide.
Australia substitute Jamie Maclaren then missed a clear opportunity at the other end when he could not make proper contact with Troisi's throughball, knocking his effort wide with only Bravo to beat.
That was to prove Australia's last opportunity, as they still wait for their first victory over Chile, whose attention now turns to Wednesday's date with Portugal in Kazan.