David Villa rendered Spain's opening game loss irrelevant by pouncing on a Chilean mistake for one goal and setting up the other in a 2-1 victory on Friday to advance in the FIFA World Cup.
Both nations finished with six points in Group H and advance, but the 2008 European champions get the edge in the group based on goal differential and play neighbours Portugal in a Round of 16 game on Tuesday in Cape Town (CBC, CBCSports.ca, 2 p.m. ET).
Chile plays Group G winner Brazil on Monday afternoon at Ellis Stadium in Johannesburg, also on CBC Sports platforms.
Chilean keeper Claudio Bravo came out to prevent Fernando Torres from being free with the ball in the first half but sent his clearing attempt right to Villa. The Spaniard was dead-on from long range, lobbing the ball into the unguarded net for his third goal of the tournament.
Villa, who also became the country's all-time leading World Cup scorer with his sixth goal, joined Argentina striker Gonzalo Higuain and Robert Vittek of Slovakia as leading scorers in South Africa with three goals.
Villa set up Andres Iniesta with a low shot to the right corner of the net later in the half. Substitute Rodrigo Millar buoyed Chile's hopes in the match early in the second with a goal, but they could get no closer.
"We have a unique opportunity," Iniesta said. "The team has demonstrated a good attitude. The draw with Portugal is difficult."
Chile is the fifth South American team to move on into the final 16, which is now fully set.
In the other group match, Honduras held Switzerland to a 0-0 draw, eliminating both teams.
Spain coach Vicente del Bosque inserted Iniesta in the starting lineup to replace Jesus Navas. Iniesta missed the last match due to a right leg injury suffered in the 1-0 upset defeat to Switzerland that opened Spain's tournament.
Mark Gonzalez started for Chile up front instead of injured Humberto Suazo. Chilean coach Marcelo Bielsa called on Jorge Valdivia and Marco Estrada filled in for the suspended Matias Fernandez and Carlos Carmona in midfield at Loftus Versfeld Stadium.
Torres, still without a goal in the tournament, burst into the box but couldn't get clear shot off in the fifth.
Marco Estrada's shot tested Spain's Iker Casillas in the 11th, and not long after, Alexis Sanchez lofted a ball that the Spanish keeper sent wide for a corner that Chile couldn't convert.
The Spanish goals came 13 minutes apart. In between, Jean Beausejour had a chance to equalize for Chile in the 34th, but Gerard Pique got his foot in the way to send the shot askew.
Torres was clipped away from the shot, with Estrada sent off due to a second yellow card.
Referee Marco Rodriguez called four yellow cards in the match, all to the South American team.
"It was even until the ejection," Chile coach Marcelo Bielsa said. "Spain's goals weren't just down to their own merit."
With Spain starting the second half slowly, Millar — who replaced Mark Gonzalez to start the half — took advantage of the time and space given to him at the edge of the area for a shot that left goalkeeper Iker Casillas without a chance.
But Spain held on for a win that ensured one of the pre-tournament favourites advanced despite not being at its sharpest.
"We know there are no easy games. We have reacted to a very difficult situation and have done well," del Bosque said. "There's a lot of pressure in Spain [for us to advance] and we want to do well."
Millar's goal to make it 2-1 came in the 47th minute, a shot that caromed off Pique's knee.
Torres, who had a penalty appeal in the 36th waived away, was replaced by Cesc Fabregas in the 55th as the Liverpool striker struggled again in his second start since undergoing right knee surgery.
What had been an entertaining game became a series of safe passes over the last 10 minutes. Both teams were evidently aware that Switzerland and Honduras were mired in a scoreless draw, paving the way for them to advance without taking risks.
Chile was the first South American team to lose a match at this year's World Cup. The Chileans will be without defender Waldo Ponce against Brazil on Monday after he picked up a yellow card in the 20th for kicking Torres.