Joao Felix produced a delicate finish to give them the lead and Rafael Leao added a third to hand Portugal their first win in the opening match of the World Cup since 2006, even if Osman Bukari pulled another one back for Ghana late on.
Portugal, who top the group with three points, next face Uruguay on Monday, when Ghana play South Korea.
Most of the action was condensed into a short period after the 60th minute with Portugal taking the lead when awarded a soft penalty after Ronaldo went down following minimal shoulder-to-shoulder contact with Mohammed Salisu.
Ronaldo closed his eyes as he waited to begin his run up, stuttered and smashed the ball into the net to the keeper's right.
Ghana fired back quickly though when Mohammed Kudus's cross found its way to Ayew who tapped home.
Portugal then revved into gear with Felix latching onto a Bruno Fernandes through ball and lifting his finish nonchalantly over the keeper.
Fernandes was the architect of their third goal too, playing another superb throughball for substitute Leao to slide his finish across the keeper and into the bottom corner.
There was tension at the end, however, as Ghana pulled another goal back with Osman Bukari heading a cross from the left in the 89th minute.