BRASILIA, Brazil — Switzerland grabbed a winner with virtually the final kick to earn a 2-1 victory over Ecuador in the World Cup on Sunday, extending a run of come-from-behind wins that are becoming a theme of the tournament.
With just seconds left in the third and final minute of stoppage time, substitute Haris Seferovic finished off a length-of-the-field move by slamming home a close-range shot. After wild Swiss celebrations, Ecuador’s shell-shocked players barely had time to restart before the final whistle was blown.
It was the fifth time in the first nine matches in Brazil that a team had come from a goal down to win — but this was the most dramatic of all the comebacks.
‘‘It was a dream to be able to win this match in the very last minute like this,’’ Switzerland coach Ottmar Hitzfeld said through a translator. ‘‘It was emotional — it will be important for the morale of the team.’’
Sluggish in the first half-hour, Switzerland — highly fancied after rising to No. 6 in the FIFA rankings — conceded a sloppy goal to go behind when Enner Valencia rose unmarked in the 22d minute and headed in a free kick from 6 yards.
Ecuador’s defending for the 48th-minute equalizer was just as abject, however, with Admir Mehmedi finding space from even closer in to nod in a corner.
With Mehmedi and Seferovic both second-half substitutes, it was no wonder that the wily Hitzfeld — a veteran coach with two Champions League titles on his résumé — had a huge grin on his face at the final whistle.
Not so his counterpart.
‘‘We were naive and that cost us the game,’’ Ecuador coach Reinaldo Rieda said. ‘‘[The loss] is more our fault. We were not beaten by our opponent.’’
After being among the bores of the last two World Cups, it was expected to be all change for Switzerland with Hitzfeld putting his faith in a young, dynamic class of 2014 that had come up together through the national youth ranks.
But nerves ensured they started the World Cup poorly, misplacing simple passes and overhitting crosses in a drab first half. The second half wasn’t much better either — but Seferovic rescued them, having only come on in the 75th minute for the ineffective Josip Drmic.
The Real Sociedad forward scored a 90th-minute winner against Cyprus in June in Switzerland’s unbeaten run through qualifying but he has lost his place to the emerging Drmic.
‘‘Haris is a striker through and through,’’ Hitzfeld said. ‘‘What he lacked was practice in terms of playing time at Real Sociedad. In the tournament build-up, he performed excellently but he still needs time to develop.’’
Seferovic scored the crucial goal, but Valon Behrami deserves just as much credit.
It was the central midfielder who produced a perfectly timed tackle in his own box and then embarked on a lung-bursting run up the field in the lead-up to the winning goal. At one stage, he was hacked down near the center circle but he got up and carried on his run, with the referee playing an excellent advantage.
The ball was fed to the left, where left back Ricardo Rodriguez — who set up Mehmedi for the equalizer — slid a low cross for Seferovic to crash a finish high in to the net.
Cue Switzerland’s entire bench spilling into the field to celebrate with Seferovic, with some players choosing to mob Behrami.
‘‘It was a great feeling,’’ Behrami said. ‘‘Those 30 seconds were amazing for us.’’
Thousands of fans missed the first part of the match because of long queues to pass through security.
It meant there were still plenty of empty seats when Valencia stole a yard on Johan Djourou and guided a simple header into the net from Walter Ayovi’s free kick, with Switzerland goalkeeper Diego Benaglio left completely stranded.