Angel Di Maria’s extra-time winner carried Argentina into the World Cup quarter-finals after an unconvincing display against Switzerland.
The two-time champions dominated possession in a turgid last-16 tie, but were unable to break through until Di Maria swept in Lionel Messi’s pass.
Switzerland defender Blerim Dzemaili headed against the Argentina post then prodded wide after Di Maria’s winner.
Argentina will now face Belgium or the USA in the last eight on Saturday.
It was a remarkable conclusion to a match that saw Argentina, rated among the favourites to win the World Cup, produce another distinctly average performance in neighbouring Brazil.
Real Madrid winger Di Maria was wasteful in promising positions throughout but kept his composure when it mattered most, coolly sweeping an angled shot into the bottom corner after Messi’s pass found him advancing into the area.
About 40,000 Argentina fans were estimated to be inside the Arena de Sao Paulo and Di Maria’s late intervention sparked wild celebrations between players and fans.
But it was a heartbreaking end for Switzerland and particularly their veteran coach Ottmar Hitzfeld, whose 31-year managerial career ended in cruel fashion.
The 65-year-old German, who was twice voted World Coach of the Year, retires after winning 19 major club trophies for Bayern Munich, Borussia Dortmund and Grasshoppers.
Argentina failed to find top form during the group stage as Messi’s brilliance inspired them to three narrow victories against Bosnia-Hercegovina, Iran and Nigeria.
And they failed to impress again as Switzerland, who progressed as Group E runners-up with wins against Ecuador and Honduras, frustrated them for long periods.