The striker won his battle against Lionel Messi at the Nou Camp as Juve topped the pool.
Weston McKennie also scored early as Juventus got the three-goal win they needed to pip their opponents to first place.
Messi drew a blank, meaning he is still two short of Pele's goal record for a single club and remains stuck on 641.
Juventus struck first after 13 minutes when Ronaldo earned a controversial spot-kick.
Ronaldo fired it down the middle, scoring for the first time in a Champions League game against a team featuring Messi.
The visitors doubled their lead seven minutes later when McKennie volleyed in Juan Cuadrado's cross from six yards after Aaron Ramsey's bustling run.
Messi was denied by Gianluigi Buffon a minute later and twice fired at the goalkeeper before the break as Barca tried to find a way back.
But Ronaldo struck again six minutes after the break when he buried his second penalty.
Antoine Griezmann's header hit the bar five minutes later and Buffon continued to frustrate Messi before Griezmann volleyed wide at the far post.
The visitors thought they had a fourth with 15 minutes left but Leonardo Bonucci's effort was ruled out for offside after he bundled in Ronaldo's knockdown.
Barcelona's 25-match unbeaten run in the Champions League group stage was over – a streak going back to 2016 – and Buffon stopped Messi grabbing a late consolation with a fine low save.