(photo credit: AP)
Spain, who trailed Tunisia for much of Monday's World Cup group game, scored three late goals in a 3-1 win and booked a place in the second round.
Switzerland and Ukraine each won to move a step closer to qualifying from their first-round groups. Switzerland beat Togo 2-0, while Ukraine trounced Saudi Arabia 4-0.
Spain trailed in Stuttgart after an eighth-minute goal by Tunisia's Jahwar Menari and appeared set for a surprising loss before a 71st-minute equalizer by Raul Gonzalez and two goals from Fernando Torres made it the eighth team to reach the second round.
Defending champion Brazil, host Germany, Argentina, the Netherlands, England, Portugal and Ecuador are already into the last 16.
For his first goal, Torres collected a pass from the halfway line, took two quick touches and flicked the ball past the goalkeeper with the outside of his right boot from the edge of the area.
His second goal was a 90th-minute penalty awarded when a defender held him to stop him from jumping for a header. That goal made him the tournament's leading scorer with three.
"We had a lot of chances, we deserved to win," Spain coach Luis Aragones said. "But we were nervous."
Having beaten Ukraine 4-0 in its opener, Spain has six points in Group H. Its best World Cup showing was a fourth-place finish in 1950. Tunisia must beat Ukraine on Friday in its last game to have a chance of advancing.
"Just at the moment when Spain started to buckle we dropped our guard," Tunisia coach Roger Lemerre said. "The decisive game will be against Ukraine and we will have to do a better job to make it."
Togo was eliminated and Saudi Arabia looks likely to join the African team.
Alexander Frei's performance in Dortmund helped Switzerland to a win that means it only needs a draw against South Korea in its last Group G game to guarantee a spot in the second round.
"We all know he can be even more efficient than we saw today, but he's coming back from a long injury period," Switzerland coach Koebi Kuhn said. "He can only improve."
Frei gave Switzerland the lead in the 16th minute, heading in a pass from Tranquillo Barnetta. Frei missed a chance to score in front of an open net early in the second half, but Barnetta added another in the 88th with a 17-meter (yard) shot.
In Hamburg, Andriy Shevchenko got a header and Serhiy Rebrov scored one of the goals of the tournament in Ukraine's 4-0 win against Saudi Arabia, which was unable to muster a single shot on goal.
Andriy Rusol had already scored from a corner, the ball bouncing off his knee and into the goal, when Rebrov hit a 35-meter (yard) shot into the right-hand corner of the net in the 36th.
Shevchenko made it 3-0 in the 46th and, with four minutes remaining, set up Maxim Kalinichenko for the final goal that completed a turnaround from the team's 4-0 opening loss to Spain.
"I think our chances of going all the way are not huge because there are stronger teams, but we will fight," Ukraine coach Oleh Blokhin said.
Australia forward Harry Kewell learned he could miss his team's crucial final group match against Croatia because he insulted a referee following Sunday's 2-0 loss to Brazil.
Kewell will have to explain his post-match comments to a FIFA disciplinary panel after German referee Markus Merk complained that Kewell had insulted him.
While Ghana has declared a half-day public
holiday for Thursday's match against the United States that could secure a second-round berth, France fans were coming to terms with the realization that they may have seen the last of Zinedine Zidane.
The playmaker is retiring after the World Cup and, after a second yellow card in Sunday's 1-1 draw with South Korea, will miss France's last Group G match against Togo.
Also, Germany's national team moved swiftly to dispel newspaper reports of a rift between starting strikers Miroslav Klose and Lukas Podolski.
"Absolute rubbish," Klose said. "I only said that he was a little tense and I meant it in a positive way."
In Cologne, police from Sweden, Britain and Germany were patrolling the streets in a bid to keep the off-field calm that has surrounded the World Cup. The patrols were expected to continue Tuesday, when England and Sweden play to decide which team finishes at the top of Group B.