Real Madrid sealed top spot in Champions League Group A with a win over Shakhtar Donetsk but were taken to the limit.
Madrid had already qualified for the next stage but now can’t be caught by Paris Saint-Germain, who recorded a 5-0win over Malmo in Sweden.
Ronaldo netted after Luka Modric sent Gareth Bale away and the Wales international hooked the ball across the six-yard box, allowing the Portuguese to convert from a tight angle.
Shakhtar were passive for much of the first half but ended on the front foot, Madrid holding on to their lead with last-gasp defending, and then building on it after the break.
Modric and Dani Carvajal netted within minutes of each other, Ronaldo each time playing a key role, as Madrid put daylight between themselves and their hosts.
Ronaldo was back scoring for Madrid’s fourth, again created by Bale, and the pair celebrated like they meant it as well amid continued rumours they don’t get along.
Shakhtar clawed a goal back when Alex Teixeira converted a penalty that was questionably awarded when Casemiro was adjudged to have fouled Taison.
They got a second when Dentinho was left unmarked at the far post from a corner and he converted with his chest, and a third through Teixeira amid some flat-footed Madrid defending.
Rafa Benitez made seven changes to the side beaten on Saturday by Barcelona, having promised to make rotations but insisted they weren’t because of the Clasico drubbing.
It took barely 90 seconds for Madrid to fashion their first chance, Ronaldo shooting over after he was teed up by Modric,
Madrid dominated the next 18 minutes but struggled to create a chance – but when they did they scored, Ronaldo and Bale combining to put the visitors ahead.
A Shakhtar free kick and near post flick on nearly caused problems for the Madrid defence before a thundering Casemiro clearance before Ronaldo perhaps should have done better when meeting a Bale cross at the far post.
Raphael Varane had to be replaced just after the half-hour with what looked like a hamstring problem, but the defender didn’t appear in great discomfort as he left the pitch.
Shakhtar did make life more uncomfortable for Madrid as the half went on, having more of the ball but without forcing Kiko Casilla into a save.
Bale crashed a shot into the arms of the Shakhtar goalkeeper but it was Shakhtar looking most dangerous as the first half ended, Alex Teixeira and Olexandr Gladkiy both having chances to level without finding the net.
Ronaldo led Madrid's break after a Casemiro ball over the top for Madrid’s second not long into the second half, holding up the ball and playing in the on-rushing Modric, who arrowed a shot into the top corner.
He was out-done by Carvajal moments later as the right back cut inside and, after taking advantage of some weak defending, curled into the far corner with his left foot.
Bale created Ronaldo’s second after regaining possession on the half-way line, haring forward and squaring to his better-placed teammate, who finished at the second attempt.
Teixeira made the score line a little more respectable despite Kiko Casilla going the right way on the penalty attempt, and it got further gloss with Dentinho’s chested contribution.
There were a handful of late scares for Madrid as Shakhtar grew in confidence and nerves were badly frayed when Teixeira found a way through to claim his second and Shakhtar’s third.
Shakhtar Donetsk 3-4 Real Madrid
Ronaldo 18, 69, Modric 49, Carvajal 51 (RM), Teixeira 78, 88, Dentinho 83 (SD)
Shakhtar Donetsk: Pyatov; Ordets, Rakitskiy, Azevedo (Dentinho 65), Stepanenko; Fred, Bernard, Marlos (Taison 62); Kobin, Alex Teixeira, Gladkiy (Ferreyra 74)
Real Madrid: Casilla; Carvajal, Pepe, Varane (Danilo 33), Nacho; Casemiro, Modric (Kroos 62), Kovacic; Ronaldo, Isco, Bale (Benzema 70)
Referee: Nijhuis [NED]