Left out of the starting line-up for this first leg of the Spanish Super Cup, Ronaldo's brilliant effort from range had restored Real's lead with 10 minutes remaining, but he was sent off shortly afterwards having picked up two yellow cards in quick succession.
To compound matters, the Portugal forward – linked with a move away from the Bernabeu this summer – then pushed referee Ricardo de Burgos Bengoetxea after being shown a red card.
Gerard Pique's own goal had put Real ahead after a low-key first half, but in a frantic finish Lionel Messi equalised from the spot before Ronaldo struck, with Marco Asensio grabbing a last-minute third for the 10 men.
Mateo Kovacic could have given Real the lead in the first minute after Marc-Andre ter Stegen's poor clearance gifted a chance to the visitors, but the midfielder's attempted lob fell into the backtracking goalkeeper's arms.
At the other end Luis Suarez tested Keylor Navas and Gerard Deulofeu failed to pick out a team-mate with his cut-back after reaching the byline.
Isco cut in from the left after 18 minutes but dragged his shot wide, and seven minutes later Messi went close with a free-kick which whistled over the crossbar.
Pique was booked for using his hand to try and convert a Barca corner, before Ter Stegen atoned for his earlier error with a smart save to deny Gareth Bale after he was picked out by Isco.
Real went ahead after 49 minutes - Isco again involved as he slipped Marcelo in down the left channel and his low cross was turned into his own net by Pique at the near post.
Deulofeu fired wide after an Aleix Vidal cross fell kindly for him at the back post and Dani Carvajal saw an effort cleared off the line at the other end as the game opened up.
Raphael Varane came close to scoring a carbon copy of Pique's own goal when he stabbed Suarez's low cross inches over his own bar.
Substitute Ronaldo found Marcelo in the 70th minute and the Brazilian was only denied by Ter Stegen's fine stop.
Sergio Busquets missed a glorious chance to level the scores when he blazed over from 12 yards with the goal at his mercy after being picked out by Denis Suarez.
However, after 77 minutes Barca did equalise. Luis Suarez was felled by Navas in the box, and Messi converted from the spot.
Ronaldo put Real ahead again just three minutes later, cutting inside Jordi Alba and firing a 20-yard effort into the top corner following an incisive break, with Isco again the provider.
However, the forward was booked for taking his shirt off to celebrate and moments later that proved crucial as he was shown a second yellow for diving after going down under pressure from Samuel Umtiti.
The 32-year-old then pushed De Burgos Bengoetxea in the back on his way off the pitch.
Asensio capped another counter-attack with a brilliant left-footed finish from the edge of the penalty area to give Zinedine Zidane's side a commanding lead going into Wednesday's return leg in Madrid.
Register for free to continue reading
Registration is a free and easy way to support our truly independent journalism
By registering, you will also enjoy limited access to Premium articles, exclusive newsletters, commenting, and virtual events with our leading journalists
Already have an account? sign in
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies