Betis had gone ahead in the 40th minute after a moment of confusion as they appealed for a penalty when Ramos collided into Nabil Fekir but the loose ball landed at the feet of defender Sidnei who rifled it into the roof of the net.
The Brazilian's joy was cut short when he was penalised for tripping Marcelo in the area and Karim Benzema converted from the spot, his first goal in seven matches in all competitions.
Betis captain Joaquin missed an open goal in the second half and Real defender Ferland Mendy hammered a shot against the bar but Cristian Tello decided an end-to-end game in the 82nd minute, keeping his composure to beat Thibaut Courtois and find the net.
His goal ensured a third defeat in four matches in all competitions for Madrid, who had also lost their last away game against Levante and were beaten in the UEFA Champions League by Manchester City last month.
After a game at home to Eibar, Zinedine Zidane's side will travel to Manchester City in the Champions League but on this evidence their hopes of recovering their 1-3 home defeat from the first leg would seem faint at best.
Ramos will be suspended at the Etihad Stadium and his own poor run of form continued against Betis, where he was at fault for their first goal and then complicit in compounding Benzema's error for the second.
Earlier Lionel Messi kept his nerve from the penalty spot to give Barcelona a 1-0 win over Real Sociedad.
The Argentinian star calmly chipped the ball into the net in the 81st minute after Real Sociedad defender Robin Le Normand had been penalised following a VAR review for hitting the ball with his arm as he contested a cross.