Substitute Haris Seferovic scored a last grasp winner for Switzerland to take his side to the top of Group E, and consign Ecuador to a damaging opening game defeat in Brasília.
Seferovic, a late second half substitute, fired in from close range after a quick breakaway from the Swiss, with Ecuador going close to a winner just moments before.
The South Americans had taken the lead in the first half, with Enner Valencia nodding in a 22nd minute corner.
Striker Admir Mehmedi, also brought on in the second half by manager Ottmar Hitzfeld, headed Switzerland level just after the restart, and the game had seemed destined for a draw before Seferovic’ late intervention.
The 22-year-old Real Sociedad attacker was on the end of a low cross from Ricardo Rodriguez after the Swiss broke with menace in the 93rd minute, sparking wild scenes of celebration from the Europeans, with the match barely able to restart with time practically up.
Switzerland take on 1998 champions France next, with Ecuador and Honduras the late kickoff later on the 20th June.