Federico Valverde put the defending champions in front from close range after 14 minutes, before Betis, managed by former Los Blancos boss Manuel Pellegrini, hit back.
Aissa Mandi headed in an equaliser after 35 minutes and William Carvalho added a second just two minutes later when he drilled past Thibaut Courtois.
An own goal from full-back Emerson levelled things up early in the second half, and Karim Benzema then saw his effort ruled out for offside.
In the 67th minute, Emerson was sent off for a second caution after foul on Luka Jovic, which was given after a VAR review and the referee checking the pitchside monitor.
With 10 minutes left, Madrid were awarded a penalty after VAR picked up a handball from Marc Bartra as the defender fell and Ramos coolly dispatched the spot-kick.