Vicente del Bosque's side needed just a point to confirm a place in the last four, but they made doubly sure thanks to a fine brace of goals from Jordi Alba and a 62nd-minute header by substitute Fernando Torres.
The world and European champions will now face Italy, who they crushed 4-0 in last year's Euro 2012 final, in the second semi-final in Fortaleza on Thursday, a day after Brazil meet Uruguay in Belo Horizonte.
Nigeria were ultimately left to rue last Thursday's damaging 2-1 defeat by Uruguay, having begun their Confederations Cup campaign with a breezy 6-1 thrashing of Tahiti.
"We played against a better side, a team who've been together for a long time," said Nigeria coach Stephen Keshi. "It's a learning process for us, it's good. We have to continue from where we stopped tonight, and build on that."
It was the teams' first meeting since Nigeria beat Spain 3-2 in the group phase of the 1998 World Cup, and if the world champions were out for revenge, they were quick to draw first blood at Estadio Castelao.
There were three minutes on the clock when Andres Iniesta sprayed a pass wide to Barcelona team-mate Alba, and the left-back weaved around three challenges before stroking a low shot past Vincent Enyeama.
Nigeria looked set for an afternoon of toil amid stifling humidity inside the stadium, but despite losing Kenneth Omeruo to injury in the 11th minute, they took the fight to Spain.
Brown Ideye and Joseph Akpala spurned half-chances, while Spain goalkeeper Victor Valdes did superbly to tip a snapshot from the recalled Sunday Mba around the post.
Despite several slick interchanges, the African champions' composure repeatedly let them down whenever they penetrated the Spanish area, but Spain were not without blame in that department either.
Roberto Soldado twice shot straight at Enyeama when clean through on goal, while Cesc Fabregas conspired to hit the post from only eight yards after being picked out by Soldado's sweeping low cross.
Ideye should have drawn Nigeria level early in the second half, but although Ahmed Musa's low centre presented him with an open goal at the back post, he miscued and was unable to dispatch a shot.
Spain introduced David Silva and Torres from the bench and within minutes of coming on, the Chelsea striker made it 2-0, flinging himself at Pedro Rodriguez's left-wing cross to score with a glorious flying header.
Having scored four times in the record-breaking 10-0 rout of Tahiti earlier this week, Torres is now the tournament's leading scorer with five goals.
Godfrey Oboabona prevented the former Liverpool man adding a third with a timely block, before substitute Muhammad Gambo spurned another good chance at the other end by slicing wide with only Valdes to beat.
Spain successfully took the sting out of the game thereafter, only for Alba to add the coup de grace in the 88th minute when he sprang the offside trap, rounded Enyeama, and rolled the ball into the net.