Iniesta also scored the first spot-kick of the shootout.
Croatia now have a golden chance to match their previous golden generation's run to the semi-finals in 1998 when they meet Russian Federation in Sochi on Saturday.
Russian Federation will now face Croatia in a World Cup quarter-final, with the latter side beating Denmark in their own penalty shootout.
Spain, who won the competition in 2010, then dominated possession, but were unable to break the hosts' stubborn defence down, and missed two penalties in the shootout, with Koke and Iago Aspas both seeing their efforts saved. Russia advanced to the Round of 16 from Group A after finishing as runners-up while Spain emerged as winners from Group B. Having surprised many by reaching the second stage, Russia, ranked 70th, will look to continue the fairytale.
He will forever be remembered for the most important goal in Spain's history to win the World Cup eight years ago, but Andres Iniesta's global career ended in sad fashion among delirium for the hosts in Moscow. Lopetegui was sacked because he had failed to tell the national soccer federation he accepted an offer to coach Real Madrid after the tournament. Turmoil erupted two days before the opening game, when the federation fired the head coach.
Spain were attempting to be patient but offered little or nothing in the way of a final pass as an increasingly tight game entered the final 10 minutes of normal time, Costa making way for Aspas in their third change. The 34-year-old Barcelona midfielder came off the bench and nearly won the game with an 85th-minute shot well saved by Akinfeev.
And it was those two who almost won it for Spain with five minutes to go, when first Iniesta and then Aspas fired shots at Akinfeev's goal - only for the skipper to parry both away.
It was all pass.pass.pass with no real objective, especially after they got the first goal through Ignashevich's own goal in the 12th minute.
So a stalemate ensued - until after a rare attack Russian Federation found their way back level via Artem Dzyuba's 41st-minute penalty after Gerard Pique's handball from a corner. Pique's complaints were wasted. "The team was under great pressure, but we supported it, and everything turned out successful", the president concluded.
After the appeals died down and Pique was deservedly booked, Dzyuba sent de Gea the wrong way and his countrymen - who filled more than three-quarters of the stadium - wild with delirium. In a match where Spain enjoyed 79 per cent of possession, not even the positive impact of another stand-out performance from Isco could break down the Russian Federation defence to give Spain the easy win many had predicted.
This World Cup has seen 132 goals so far and we've seen some scintillating ones, but we've also had a fair share of "freak" goals.