City's Bernardo Silva and Mateo Kovacic both misfired in the shootout to put Madrid in the driving seat
Ronaldo blasted Portugal ahead from a free kick in the first half but the game turned dramatically early in the second.
Portugal were awarded a penalty for a foul on Bernardo Silva but the referee then decided to review an incident at the other end which happened immediately beforehand.
He then awarded a spot kick to the Swiss instead which Ricardo Rodriguez converted in the 57th minute to equalise.
With the game heading for extra time, Ronaldo blasted home from Bernardo Silva's pass in the 88th minute and completed the win by curling the ball past Yann Sommer two minutes later.