Karim Benzema cancelled out a header from Gerard Pique to leave the two teams on terms entering the latter stages, but Ronaldo netted five minutes from time as Los Blancos won the La Liga contest in Catalonia, despite being reduced to ten men late on when Sergio Ramos was given his marching orders.
Barcelona remain top of the table on 76 points - six clear of second-placed Atletico Madrid, while Real Madrid have moved to within seven of Luis Enrique's side and to within one of their capital rivals with seven games of the season left to play in Spain's top flight.
There were no surprises in Luis Enrique's selection, with the Spaniard naming his strongest available team. Andres Iniesta was a slight doubt before the match, but the midfielder was passed fit to skipper the Catalan outfit. Attacking trio Luis Suarez, Lionel Messi and Neymar were also all in the XI despite long trips back from South America following international duty.
Like Barcelona, Los Blancos also had their first-choice front three available, with Gareth Bale and Benzema joining the league's top scorer Ronaldo in the final third of the field.
Ahead of kickoff, both clubs paid their respects to the late Johan Cruyff, who lost his battle against cancer earlier this week. The Dutchman represented Barcelona as a player between 1973 and 1978, before managing the Catalan side between 1988 and 1996. At the helm, Cruyff led the Spanish giants to four La Liga titles and the 1992 European Cup and was given a brilliant send-off at Camp Nou.
The first real chance of the match came to Barcelona in the tenth minute when Neymar drove away from Ramos before feeding a cross into Suarez, but the striker, under no pressure, somehow failed to make contact from close range, much to the relief of the away team.
The 14th minute brought a spell of applause for Cruyff as those in attendance paid their respects once again, and it was Barcelona that continued to look the most likely to break through a nervous Real Madrid backline.
Messi bent a free kick just over the Real Madrid crossbar as Barcelona came close once again in the 19th minute, before Keylor Navas got down to keep out a low strike from Ivan Rakitic within the next 60 seconds.
Barcelona had a strong penalty shout in the 24th minute when Messi went down under contact from Ramos, but the referee was not interested, despite replays showing that clear contact was made. Had the Spanish official pointed to the spot or indeed for a free kick just outside the box, a second yellow for Ramos would have surely arrived.
© Getty Images
Real Madrid went straight down the other end and came close on two separate occasions, but Ronaldo's strike was palmed away by Claudio Bravo, before Bale fired over the crossbar from a wide angle.
Ronaldo then had the chance to line up a set piece in the 30th minute as Real Madrid began to threaten on the counter-attack, but the Portuguese just missed the target during a disappointing half of action.
Real Madrid's best opportunity of the first 45 minutes came in the latter stages of the half when Benzema found himself free inside the Barcelona box, but the Frenchman cleared the crossbar as it remained all square at the break.
Ramos was again fortunate to escape a second yellow early in the second period when he dived into the back of Suarez, but the resulting free kick from Messi was never troubling Navas in the Real Madrid goal.
An inventive chip from Messi almost caught out Navas in the 55th minute following a swift Barcelona move involving Neymar and Suarez, but the stopper flew across his goal to make a fine stop and keep the two teams on terms.
Barcelona were ahead in the 57th minute, however, when Pique, who had slipped Pepe inside the box, headed a Rakitic corner past Navas from close range to send the home supporters into jubilation.
Real Madrid were back on terms in the 62nd minute though as Benzema produced a volley from inside the box after a cross from Kroos had been deflected into the vicinity of the centre-forward.
© Getty Images
Bale had the ball in the back of the net in the 80th minute when he headed past Bravo from close range, but the referee blew late for a free kick on Jordi Alba, before Ronaldo rattled the Barcelona crossbar moments later.
Real Madrid were eventually reduced to 10 men in the 83rd minute when Ramos picked up a second yellow for a terrible challenge on Suarez and it was the last in a long list of poor tackles from the Spanish international on the night.
It was the visitors that continued to drive forward, however, and Zidane's team won it five minutes from time when Ronaldo controlled a cross from Bale before firing home from close range to silence Camp Nou and ensure that Real Madrid gained revenge for their Bernabeu embarrassment earlier this season.