It came down to the wire for the hosts as Spain were unable to break down Russia's dogged defending that led to a penalty shoot out, with goalie Igor Akinfeev becoming Russia's newest hero.
Hosts Russia beat Spain 4-3 on penalties thanks to two saves by their goalkeeper Igor Akinfeev on Sunday to advance to the World Cup quarter-finals where they will face either Denmark or Croatia.
Akinfeev saved Koke's and Iago Aspas' spot kicks after both teams had scored two apiece in what was Russia's first ever World Cup penalty shootout, to send his team to the last eight after a lacklustre 1-1 draw over 120 minutes.
But there was high drama in the shootout for the 78,000 spectators at Luzhniki Stadium, with all four Russian penalty-takers keeping their cool and Akinfeev saving Aspas' spot kick with his foot to trigger wild celebrations.
"In the second half, we were trying to defend. We were hoping for penalties and that's what happened, thank God," Akinfeev said. "We are having a fantastic World Cup."
Spain, who have never beaten a host at World Cups or Euros, went ahead after 12 minutes when 38-year-old Sergei Ignashevich bundled into Spaincaptain Sergio Ramos at the far post, knocking a free kick in with his heel for the 10th own goal of the tournament.
The 2010 world champions controlled the game with their slick passing but failed to add to their lead as the Russian's defended with discipline.
They looked, however, equally toothless up front, with Aleksandr Golovin's curled effort their only noteworthy opportunity until Gerard Pique's handball gave them a chance to level with a penalty in the 42nd minute.
Forward Artem Dzyuba buried it for his third goal of the tournament, sending Spain keeper David de Gea the wrong way to equalise and awaken the subdued crowd.
The game lacked pace and tempo even after the break with both teams cautious not concede too much space and the Russians playing without an out-and-out striker after the substitution of Dzyuba.
Despite 75 percent possession, Spain's famed tiki-taka passing game rarely carried them into the box and they had to wait until the 85th minute to test Akinfeev with a low drive from substitute Andres Iniesta.
Having long run out of steam and with several players cramping, Russia were reduced to desperately defending in extra time as Spain, who played more than four times the number of passes their opponents did, still struggled to create clear chances.
Akinfeev came to the rescue again to deny Rodrigo after his fine sprint in the second half of extra time before becoming a national hero by saving the two spot kicks to send the hosts past the former world champions.