MOSCOW  — Stretching every part of his body out into a star shape and diving to his right, Igor Akinfeev flicked out his left foot and kicked the ball high away from danger.

Akinfeev’s foot kept Russia’s party going Sunday night, ended the international career of one of Spain’s biggest stars and sealed the biggest upset of the tournament and one of the greatest in World Cup history.

Akinfeev saved two shots during the shootout, while all of his teammates scored to give Russia a 4-3 advantage after a draw that was dominated by Spain in every way but the 1-1 score. Russia — the lowest ranked team in the World Cup at No. 70 in the world — is stunningly going to the quarterfinals to face Croatia on Saturday.

Millions of Russian fans, many of whom were mocking this team just a couple of weeks ago, are jumping loudly on the bandwagon.

“We’re hosting a fantastic tournament,” Akinfeev said. “I think our fans and foreign fans have recognized that we’re a country that can play football and organize big events.”

Akinfeev’s winning save against forward Iago Aspas made the national stadium in Moscow shake with the roar of around 70,000 Russians celebrating their team’s best World Cup run since it was the Soviet Union in 1966.

It was a shocking elimination for Spain, joining former champions Germany and Argentina. Still, World Cup history was on Russia’s side after its well-organized team survived two hours of barely having the ball.

Russia extended a streak of World Cup hosts winning penalty shootouts to five. France, South Korea, Germany and Brazil have also won shootouts since 1998.

Akinfeev ensured that, in the 32-year-old captain’s 111th game for his country.

With Spain taking first, the shootout was poised at 2-2 when Akinfeev dived to his right to push away the kick by Jorge “Koke” Resurreccion. The Atletico Madrid midfielder lifted his shirt over his eyes in dismay.

Russian penalty kickers were perfect against Spain’s struggling goalkeeper David De Gea. After Akinfeev acrobatically blocked the left-footed shot of Aspas, he leapt up, punched the air with both hands and dove into a belly flop cross the rain-soaked turf as teammates raced to him from the halfway line.

“I just feel emptied out,” Akinfeev said. “Over the whole second half and extra time we were defending our goal and managed it, we were hoping for penalties because Spain are hard to beat.”

It gave Russia its greatest win in 10 years, since Akinfeev was in goal for an extra-time victory over the Netherlands in a European Championship quarterfinal. That run was ended days later by a Spain team beginning its era of dominance.

Spain has now failed to win a knockout game at three major tournaments since it won Euro 2012, its third straight major title after Euro 2008 and the 2010 World Cup.

It was too passive a performance by the Spanish, who were ranked 10th and among the pre-tournament favorites. Turmoil erupted two days before the opening game, when the federation fired the head coach.

“It’s painful, there’s nothing else we can say,” Spain captain Sergio Ramos said. “We left our soul in the pitch.”

It is unclear if interim coach Fernando Hierro will continue in a job he did not seek before Julen Lopetegui was sent home. Lopetegui was fired because he didn’t tell Spain’s soccer leaders he accepted an offer to coach Real Madrid after the tournament.

Sunday’s defeat ended Andres Iniesta’s Spain career. The 34-year-old Barcelona midfielder came off the bench and almost won the game with an 85th-minute shot well saved by Akinfeev. Iniesta also scored the first spot-kick of the shootout.

Spain was more urgent in extra time after being too passive for 90 minutes. Though Spain completed a World Cup game record of 1,029 passes, it rarely threatened Akinfeev’s goal.

Spain led in the 12th minute when Ramos helped force Russia’s Sergei Ignashevich into an own goal when his back was turned to the play. Ramos and Ignashevich got tangled up and the ball went in off the Russian defender’s heel.

A defensive error let Russia level in the 41st, after Gerard Pique’s raised arm blocked a header by Artyom Dzyuba. Dzyuba’s penalty kick fooled goalkeeper David De Gea to dive the wrong way.

“We’re insanely happy,” Dzyuba said. “We’ve given everyone a party and we believed in ourselves to the end. We believed that order, discipline and dedication can beat class.”

SPECIAL GUESTS

King Felipe VI of Spain was at the Luzhniki Stadium in Moscow. The king is a soccer fan who, as crown prince, attended the 2010 World Cup final in Johannesburg to see Spain beat the Netherlands 1-0.

Russia was represented by Prime Minister Dmitry Medvedev, who was on his feet and leaning on a protective barrier to watch the shootout.

FOURTH SUBSTITUTE

World Cup history was made with the first use of a fourth substitute, which FIFA now allows teams in extra time. Russia’s Alexander Yerokhin went on in the 97th minute against Spain, replacing fellow midfielder Daler Kuzyaev.

ONE SAVE

De Gea made one save at the entire World Cup, and none Sunday when Artyom Dzyuba’s 41st-minute penalty was Russia’s only shot on target. Russia then scored all four spot-kicks in the shootout.