David Villa snatched a late winner to book Spain's first appearance in a World Cup semi-final as they beat Paraguay in a largely disappointing quarter-final tie that nonetheless boasted moments of incredible drama.
Villa's goal after 82 minutes - his fifth of the tournament- struck one post, rolled across the goal-line and hit the other, before finally nestling in the net and came seconds after substitute Pedro had also hit the woodwork.
It was heartbreaking for a Paraguay side that had never reached the quarter-final stage before, and who earlier wasted a superb chance to take the lead when Oscar Cardozo's spot-kick was saved by Iker Casillas.
That came after 57 minutes - and before the tie reached the hour mark Spain had also been awarded a penalty by referee Carlos Batres.
In a truly remarkable passage of play, Xabi Alonso scored his first effort but the retake, which came because Spanish players encroached into the area, was saved.
Goalkeeper Justo Villar then appeared to foul Cesc Fabregas as he scrambled to collect the rebound but a third penalty award was not forthcoming, while Sergio Ramos pounced on the loose ball but his shot was blocked on the line.
In truth, it was a brief flurry of excitement that was largely out of kilter during a game that saw relatively few other opportunities.
Spain may have reached a World Cup semi-final for the first time - their fourth place in 1950 was after a round-robin stage - but they will surely need to improve if they are to defeat in-form Germany in Durban on Wednesday.
Their famed passing game was largely absent, while the out-of-form Fernando Torres was withdrawn after 56 minutes.
Paraguay started at a decent pace, certainly settling much quicker than Spain, and created some promising openings.
Jonathan Santana forced a saved with a low strike inside 60 seconds, while Spain consistently struggled to deal with crosses from wide areas.
Sunderland-bound Cristian Riveros headed wide, while Antolin Alcaraz and Santana both peeled away from their markers with far too much ease but could not quite make the decisive contact.
Nelson Valdez, one of six changes from the side that defeated Japan in Pretoria, slotted home from close range shortly before the break but the effort was ruled out by a marginal offside decision.
The Borussia Dortmund forward certainly appeared to be onside but there was a doubt over Cardozo, who attempted but failed to head the cross that eventually fell to Valdez.
At one point Spain looked as though they were starting to gain a measure of control in midfield but Paraguay, who would have topped South America's World Cup qualifying group if they had won their final game, slowed the match down at every opportunity.
Gerardo Martino's team also worked extremely hard to thwart Spain's passing game and looked extremely dangerous on the counter, with the lively Valdez wasting a decent position with an atrocious shot just before the interval after a sharp break.
Xavi went close for Spain with one piece of brilliance, deftly flicking the ball up with one touch before shooting on the turn in a manner reminiscent of a goal Thierry Henry once scored for Arsenal.
However, the midfielder's shot flew narrowly over and it was a slightly disjointed and frustrated Spain that left the field to regroup at the break.
The tie exploded into life with the back-to-back penalties and all the shenanigans that surrounded them.
There was little doubt that Gerard Pique fouled Cardozo for the first when he clung onto the Benfica forward, but the Paraguayan's subsequent penalty was struck at a good height for Casillas.
From the very next attack Alcaraz was adjudged to have brought down Villa, with Alonso comfortably slotting home first time around.
Replays did suggest referee Batres was correct to order a retake - and the prayers of Valdez, who was on his knees just outside the penalty box, were answered when Alonso saw his effort saved and Spain failed to score.
But there was nothing Valdez could do to prevent the prolific Villa from equalling Emilio Butragueno's Spanish record of five goals at a World Cup finals, which was set in 1986.
Villar saved from Iniesta shortly after Spain's goal, but Paraguay did have a chance to equalise late on only for Casillas to block substitute Roque Santa Cruz's effort.
The Paraguay keeper denied Villa as Spain threatened on the break in the final seconds but a second goal would have been harsh on the South American side, who conceded just twice in their five games in South Africa.
Attempts on target
Attempts off target
Projected table based on current scores
|Group A teams||P||W||D||L||F||A||GD||PTS|
|Group B teams||P||W||D||L||F||A||GD||PTS|
|Group C teams||P||W||D||L||F||A||GD||PTS|
|Group D teams||P||W||D||L||F||A||GD||PTS|
|Group E teams||P||W||D||L||F||A||GD||PTS|
|Group F teams||P||W||D||L||F||A||GD||PTS|
|Group G teams||P||W||D||L||F||A||GD||PTS|
|Group H teams||P||W||D||L||F||A||GD||PTS|
Copyright © 2015 BBC. The BBC is not responsible for the content of external sites. Read more.