Spain's unquestionable class was just enough to edge them past a talented but ill-disciplined Chile team who deservedly joined the European champions in qualifying for the World Cup's knockout stages.
Vicente del Bosque's side have still not clicked in South Africa - and the South Americans put them under real pressure before being controversially reduced to 10 men just before half-time in Pretoria.
But flashes of individual brilliance from striker David Villa and fit-again midfielder Andres Iniesta sealed a last-16 clash against Portugal on Tuesday as they ran out Group H winners despite a shock defeat to Switzerland in their opening match.
Chile, who picked up seven red cards in qualifying, must face five-time winners Brazil on Monday without their strongest team after three key players were lost to suspension in a first half they threatened to take charge of with admirable invention before losing their heads.
After dominating possession but failing to score in that surprise 1-0 loss to the Swiss, Spain vowed they would not sacrifice their rich attacking instincts for a win-at-all costs philosophy.
Needing three points to guarantee progression, they started this match on the front foot - but Fernando Torres spurned two half-chances and the Liverpool striker clearly looks like a man still feeling his way back after injury.
Yet the European champions were soon being cut open as Chile, whom some observers consider to be a South American version of Spain, attacked them with short incisive passes and constant movement off the ball in support of their team-mates.
Coached by Argentine Marcelo Bielsa, they could have taken a 10th-minute lead after a brilliant move saw Jean Beausejour - a winger who plays for Club America in the Mexico - execute a clever one-two with Jorge Valdivia, but Mark Gonzalez failed to connect properly with his low cross.
In a rare struggle to monopolise the ball, Spain looked riled - but while Chile worked overtime to establish the upper hand they lost their discipline - both Gary Medel and Waldo Ponce were rightly booked for nasty tackles and will miss the match against Brazil.
Firmly against the run of play, Spain's first goal came fortuitously.
Gerard Pique over-hit a long pass out of defence - which the out-of-sorts Torres was never likely to reach - but Chile goalkeeper and captain Claudio Bravo foolishly raced out of his penalty area to clear unsuccessfully into the path of Villa.
Lurking near the left touchline as the ball squirmed towards him, Barcelona's new £35m signing Villa instantly guided it over Bravo into the net - with his weaker left foot - from all of 40 yards.
Undaunted, the ever-threatening Beausejour raced away from Spain's back-line as he nearly created a dangerous one-on-one with keeper Iker Casillas - but Pique sped back to make a crucial block.
Clever Iniesta, who has struggled for fitness in the past three months, then gave Spain what looked like some breathing space with a typically classy second goal, executing snappy give-and-go exchanges with first Torres and then Villa before coolly guiding the ball into Bravo's far corner with breathtaking simplicity.
The biggest flashpoint moment of the match occurred in the build-up to that goal, as Torres went down following his pass after what looked like an accidental trip from behind by Marco Estrada.
Referee Marco Rodriguez obviously saw the incident differently as he gave Estrada a second yellow card.
Only when Chile were down to 10 men did Iniesta and Xavi start dictating the flow of the match with the cute passing triangles they execute for Barcelona week-in week-out.
Recognising this, Bielsa made two changes at half-time - and three minutes after the interval substitute Rodrigo Millar, who had replaced Gonzalez, put the South Americans firmly back in to the match.
Finding space for himself among a posse of defenders outside the box, his snapshot took a wicked deflection off Pique to loop high past a flailing Casillas.
Chile now needed just one more goal to put themselves back in the frame to finish top, but Spain had just enough about them to take advantage of the extra man.
With Torres clearly struggling, on came Arsenal captain Cesc Fabregas in his place as Del Bosque tweaked his side's formation to leave Villa - who now has three goals from this tournament - at the spearhead of their attack.
Although he thrived off the responsibility and set about terrorising the manful Chile defence with real adventure and wit, clear chances were at a premium as the match became more squeezed with both teams eyeing greater challenges ahead; namely a place in the quarter-finals.
Source: BBC Sport