Villa strike sends Spain through
The match was billed as a meeting between the second- and third-ranked teams in the world but the 1-0 scoreline gave little sign of the real gulf between the Iberian neighbours.
The European champions now face Paraguay on July 3 and have a strong chance of reaching only their second World Cup semi-final and the first for 60 years.
"We always controlled the game but in the second half we were better than Portugal, we had greater depth in our game and we controlled very well," said Spain coach Vicente del Bosque.
Cristiano Ronaldo was a peripheral figure for Portugal, who clocked a couple of decent first-half chances but had few complaints after failing to score for the third time in four games in South Africa.
"Given the number opportunities, Spain had their victory and it sits well with what happened in the game," said coach Carlos Queiroz.
"It must be recognised that Spain moved the ball extremely well and had a greater degree of possession.
"We had a number of opportunities but we allowed Spain to play the same type football up to the point where they scored."
Spain looked dangerous from the off as Fernando Torres and Villa stung goalkeeper Eduardo's palms three times cutting in from the left in the opening seven minutes.
Portugal plugged that gap however and, settling about their task, worked hard to ensure Spain's crisp passing made patterns in the midfield instead of inroads towards goal.
Portugal actually had the clearer chances of the first half as a swerving Ronaldo free-kick almost got past Iker Casillas while striker Hugo Almeida missed a great headed opportunity.
Spain continued to dominate possession after the break but struggled to find a way through until Del Bosque's inspired substitution after 58 minutes.
A weary-looking Torres gave way to Fernando Llorente and two minutes later the big striker forced Casillas into a great save with his first touch - a diving header.
His presence upset Portugal's concentration and spurred Spain to accelerate their approach.
It paid off decisively in the 63rd minute when after another crisp move from deep, Xavi cleverly rolled Andres Iniesta's pass into the path of Villa and though the forward's left-foot shot was saved he reacted quickly to ram in the rebound with his right for his fourth goal of the tournament.
Sergio Ramos, Villa and Llorente all went close to a second, with Eduardo keeping his side clinging on.
But in reality Portugal, semi-finalists four years ago, were going out of the tournament and like a leaf in a whirlpool there was absolutely nothing they could do about it as Spain's incomparable possession play deprived them of the ball.
Portugal's disappointing night was completed with a harsh red card for Ricardo Costa after a mild off-the-ball clash with Joan Capdevila but Spain march on.
"It was a great collective effort, we tied to keep possession, keep the style of football we've been playing," said man of the match midfielder Xavi.
"I think this is the best match we've played in this World Cup."