Barcelona remain just a point behind the European champions having played a game more as Neymar and Lionel Messi both scored twice in a 6-0 win at 10-man Elche yesterday.
Madrid got off to the worst possible start when Sergio Ramos handled inside his own area and Nabil Ghilas slotted home the resultant penalty.
Karim Benzema levelled from James Rodriguez's corner midway through the first-half, but Ronaldo's frustration at a poor performance seemed to have cost his side the chance of victory when he lashed out at Edimar seven minutes from time.
"I apologise to everyone and especially to Edimar for my rash act in the game today," Ronaldo wrote on his official Twitter account.
Also Read
"I haven't seen it yet and I still haven't spoken with him so I can't judge," Madrid boss Carlo Ancelotti said of Ronaldo's dismissal.
"We suffered in this game, but it is was important to get the three points and we managed to do it."
Slowly, though, Madrid began to find their feet and drew level on 27 minutes when Rodriguez's corner was flicked on by Bale and Benzema slammed home his 15th goal of the season from close range.