The Real Madrid defender, 33, broke the deadlock at his club’s home ground, scoring a second-half penalty for his 20th goal from 165 caps.
Striker Alvaro Morata, 26, also scored a spot-kick in Madrid before fellow substitute Mikel Oyarzabal, 22, scored his first international goal.
Spain are now five points clear of Sweden at the top of Group F.
Before the game, Ramos was presented with a commemorative plate after Friday’s 4-1 win in the Faroe Islands saw him pass former team-mate Iker Casillas’ record for most international wins by a player.
The Porto goalkeeper played in 121 victories from 167 internationals so Ramos is also now two behind Casillas’ record as Spain’s most-capped player.