Barcelona's new signing scored broke the deadlock just after the hour mark to end Spain's frustration against a defensively-minded and unambitious Portuguese side, who ended the game with 10 men following the late dismissal of Ricardo Costa.
The pre-tournament favourites will now meet Paraguay, who beat Japan on penalties in the day's early kick-off, in the last eight on Saturday.
Considering the wildly differing approaches to the game, victory was nothing less than the forward-thinking Spanish deserved, even though Portugal had several opportunities on the break to find the back of the net.
Vicente Del Bosque's side roared out of the blocks and forged three good opportunities within the first seven minutes of play, although none were taken.
Fernando Torres, yet to get off the mark at this tournament, sounded Spanish intent with not even a minute on the clock, his crisp strike stinging the fingers of Eduardo.
The keeper was again brought into action two minutes later as David Villa let off a strike on goal before the new Barcelona striker cut inside and let fly with another effort that Eduaro was forced to deal with.
Xavi nearly caught out the Portuguese number one on 12 minutes with a smart first-time effort that looped just over the bar, but Carlos Queiroz's back line stood firm in the face of the early pressure.
And having survived the initial onslaught, Portugal soon settled into their game, which consisted of sitting 10 men behind the ball and waiting to hit on the break.
That gameplan nearly paid off when Tiago fired a 20th-minute shot on the break which Iker Casillas could only parry into the air. Hugo Almeida tried to get to the loose ball but the Spaniard recovered in time to clear to safety.
Real Madrid keeper Casilllas again looked shaky on 28 minutes when he fumbled club-mate Ronaldo's viciously swerving free-kick, and the World Player of the Year was then frustrated when Almeida went for a header, which he put wide, when he was waiting to pounce just behind.
Ronaldo was to do little else for the remainder of the game, and he joins the likes of Wayne Rooney as one of the biggest disappointments of the tournament.
That said, with the score goalless at the break, Queiroz must have been the happier of the two coaches as, after that early salvo, the Spanish had been largely frustrated.
The ineffectual Torres was replaced by Fernando Llorente on 59 minutes and the change appeared to give the Spanish renewed vigour.
The Athletic Bilbao striker nearly opened the scoring with a diving header with virtually his first touch before Villa flashed a shot inches wide of the post just seconds later.
Buoyed from those two chances, Spain finally broke the deadlock in the 63rd minute following a lovely crisp passing move involving Andres Iniesta and Xavi Hernandez before Villa applied the finishing touch at the second attempt, having seen his first stab at goal repelled by Eduardo.
Sergio Ramos was denied a second on 70 minutes by a wonderful stop by Eduardo before Llorente saw a fierce drive saved by the keeper and then glanced a header go wide as full-time approached.
Despite a late bid to find an equaliser, Portugal's involvement at the World Cup ended on a sour note as the game became a little fractious and Costa was dismissed following an off-the-ball clash with Joan Capdevila.
Match stats
Spain v Portugal
Goals 1-0
1st Half Goals 0-0
Shots on Target 8-3
Shots off Target 5-4
Blocked Shots 5-2
Corners 6-3
Fouls 13-18
Offsides 0-3
Yellow Cards 1-1
Red Cards 0-1
Passing Success 89.5%-75.6%
Tackles 16-28
Tackles Success 62.5%-89.3%
Possession 64.5 %-35.5%
Territorial Advantage 56.1%-43.9%