Substitute Haris Seferovic scored in the third minute of stoppage time to earn Switzerland a dramatic win over Ecuador in their opening Group E match.
Seferovic turned in Ricardo Rodriguez's low cross as Ottmar Hitzfeld's side came back from behind to claim victory.
Fellow substitute Admir Mehmedi headed Switzerland level after Enner Valencia had given Ecuador a half-time lead.
Valencia's header from a Walter Ayovi free-kick was his fifth goal in successive games for his country.
Hitzfeld's two substitutions were key to turning around a match that looked to be slipping away from his side after a poor first-half display.
The coach, a Champions League winner with Borussia Dortmund and Bayern Munich, is retiring at the end of the World Cup - and has set himself the target of guiding Switzerland to their first quarter-final since 1954.
They arrived in Brazil as Group E seeds and ranked sixth in the world, but struggled in the face of an energetic first-half Ecuador performance.
Reinaldo Rueda's side are keen to make an impact in Brazil to provide a fitting tribute to forward Christian Benitez, who died of heart failure last summer.
They restricted Switzerland to threatening with long-range shots and set-pieces during the opening 45 minutes, with keeper Alexander Dominguez keeping out efforts from Xherden Shaqiri, Rodriguez and Gokhan Inler.
And Ecuador went in front midway through the first half, helped by some poor Swiss defending at a free-kick.
Hamburg's former Arsenal defender Johan Djourou - preferred at centre-back to Basel's Fabian Schar - was culpable as striker Valencia was left unmarked six yards out to head in Ayovi's delivery from the left midway through the first half.
But Ecuador's lead was wiped out early in the second half from a near-identical set-piece as their defence switched off.
Rodriguez whipped a corner towards the near post and Mehmedi, Freiburg's leading scorer in the Bundesliga last season, got above Carlos Gruezo to head in.
Ecuador's exciting but inconsistent winger Jefferson Montero threatened to restore their lead by sprinting past Stephan Lichtsteiner to power in a shot that keeper Diego Benaglio beat out at the near post.
Switzerland then enjoyed a good spell of pressure as their opponents appeared to tire, and Josip Drmic turned the ball into the net from a Rodriguez through-pass, but was ruled offside.
Then Bayern Munich forward Xherdan Shaqiri fired wastefully into the side-netting from a tight angle with two men in support after being played in by Mehmedi.
Switzerland had to survive several scares in the closing stages, though, with Valencia almost grabbing a second after a mix-up between Djourou and Benaglio, before the keeper pushed away Michael Arroyo's deflected free-kick.
Hitzfeld's side pulled through and clinched victory on the break as Rodriguez charged down the left and crossed low for Real Sociedad striker Seferovic to convert at the near post.