The 28-year-old struck his fifth goal of the finals to send the perennial underachievers to their first-ever World Cup semi-finals.
- Paraguay 0-1 Spain - As it happened
It was tough on Paraguay who had matched the European champions for much of the game - and though this has been a World Cup of shocks, the needle would have gone off the Richter scale if the South Americans had triumphed.
Spain now face Germany in the semi-finals - not since 1950, where they were part of a four-team final group, have they had such an opportunity to reach the final itself.
Both sides contrived to miss penalties before Villa came up trumps after Andres Iniesta had carved out an opening for Pedro, who hit the post with his new Barcelona team-mate producing the perfect follow up.
Until then, Paraguay coach Gerardo Martino, who made no fewer than six changes from the side that scraped past Japan on penalties, had got his tactics just right.
Spain's coach Vicente del Bosque kept faith with the same starting line-up for the third game in a row but familiarity bred contempt for the first hour.
Paraguay could have gone ahead in the very first minute had they taken advantage of an excellent opening.
The Spanish defence was split open by Oscar Cardozo who found Jonathan Santana on the edge of the box but his shot was tame and Iker Casillas was not troubled.
Cristian Riveros headed over as Paraguay continued their refusal to be overawed while Xavi, dogged by Cristian Riveros snapping at his heels, had a poor first half. Those usually laser-guided missiles from his boot looked as though the control system had gone wonky.
Spain failed to bring a single save out of Justo Villar in the first 45 minutes - Xavi's spin and volley that dipped just too late their one highlight, while Fernando Torres looked woeful.
After Joan Capdevila's free-kick was blocked, a break by Paraguay saw a stunning cross by Claudio Morel that was just missed by Santana.
Villa, who had looked the liveliest of the off-colour Spaniards, dragged a chance wide before Paraguay were controversially denied the lead.
Nelson Valdez brought down the ball and finished expertly but was flagged offside - replays showed he was just on - and he put his next chance high and wide after turning Carles Puyol inside and out at pace.
After 10 minutes of the second half del Bosque had seen enough and he sent on Cesc Fabregas for Torres and suddenly a drab game exploded into life.
Paraguay were awarded a penalty after Gerard Pique hauled down Cardozo. The Benfica forward dusted himself down and stepped up but Casillas saved low to his left.
Almost immediately referee Carlos Batres from Guatemala awarded a spot-kick at the other end after Villa was felled by Antolin Alcaraz. Xabi Alonso put it away only to be made to re-take it due to encroachment and this time Villar came up trumps - and he then got away with clipping Fabregas who reached the loose ball first.
Iniesta, who had been much subdued, suddenly woke up and brought a terrific save out of Villar with a curling effort, then lofted another effort high over the bar.
Fabregas' hustling saw Xavi presented with a shooting chance and he hit it almost too well as it whistled past the post.
With seven minutes left Spain finally produced a goal worthy of their lofty reputation when Iniesta went on a fantastic run and set up Pedro whose shot hit the post, with Villa reacting instinctively to fire it in off the other upright. Now he has 43 goals for his country, only one behind Raul.
It was left to Casillas to rival Villa as Spain's hero with a double save in the dying seconds to keep out Lucas Barrios and Roque Santa Cruz.