The home side dominated the opening stages, but it was the Spanish who drew first blood with less than 10 minutes on the clock as Jordi Alba headed Marco Asensio's cross into the top corner from inside the 18-yard box.
The visitors doubled their advantage just after the half-hour mark when Daler Kuzyaev was penalised for a handball inside the area, allowing Ramos to step up and place the ball beyond Andrey Lunev from 12 yards.
The World Cup hosts were level just after the interval as Yuri Zhirkov's cutback found Miranchuk in front of goal, allowing the Lokomotiv Moscow midfielder to stroke the ball past De Gea to make it 2-2.
End-to-end action followed and Spain were back in front in the 53rd minute, moments after Giorgi Jikia had pulled Ramos to the ground in the box to hand Spain another penalty.
The Real Madrid captain stepped up again and ploughed the ball into the top corner, leaving Lunev standing.
Russia's second equaliser of the evening came in spectacular fashion in the 70th minute as Smolov curled a screamer into the top corner from outside the box, with De Gea swiping at air.
The hosts had the chance to win it five minutes from the end when Smolov, on a hat-trick, found himself clean through on goal, but De Gea made himself big to keep the scoreline at 3-3, and that is the way it stayed.