Federico Valverde put Madrid ahead from close range but Aissa Mandi – with a header – and William Carvalho scored two quickfire goals as Betis led.
Madrid were level early in the second half through an own goal by Emerson, who was later sent off by the VAR for a professional foul on Luka Modric.
Sergio Ramos scored the winner with a chipped penalty.
There was a long VAR check for both those decisions, with the penalty disputed because Betis’ Marc Bartra was penalised for a handball as he put his arms out, falling under pressure from Borja Mayoral.
That was Real Madrid’s first win of their title defence, after a 0-0 draw with Real Valladolid last weekend.
Barcelona start their season at home to Villarreal on Sunday.