Betis had got themselves back into the game after going a goal behind early on but a red card for Emerson allowed Madrid to capitalise in the final stages and claim all three points at the Benito Villamarin Stadium.
Madrid took an early lead in the 14th minute when Karim Benzema ran down the right before sending in the cross for Federico Valverde to poke into the back of the net from close range for his first goal since November.
Just after half-time, Emerson gifted Real the equaliser, turning the ball into his own net from a Dani Carvajal cross under pressure from Benzema.
Betis were unable to hold out for the draw after a penalty was awarded to Madrid on VAR review for a Marc Bartra handball in the 82nd minute. Ramos beat Joel from the spot to secure all three points for the visitors.