After Barcelona were held by Atletico Madrid earlier in the week, Real won 1-0 on Thursday night to pull further clear of their two nearest rivals at the summit.
Getafe more than held their own at the Bernabeu for much of the evening until the hosts were awarded a penalty 12 minutes from time.
Dani Carvajal was tripped by Mathias Olivera after cutting back inside the box and Ramos made no mistake from the spot, scoring his 21st successive penalty to earn Zinedine Zidane's side a hard-fought three points.
He did turn home the equaliser for Sociedad, who wrapped up a 2-1 win courtesy of substitute Alexander Isak's effort.
In Serie A, Atalanta took a firmer hold of fourth place and the final Champions League qualification spot following a 2-0 home win over Napoli.
Ilija Nestorovski secured a 2-0 victory, coming off the bench to score at the end of an Udinese counter-attack.
Meanwhile, the first leg of the Bundesliga relegation play-off ended goalless as Werder Bremen's 39-year stay in the top flight remains in doubt.