The victory has moved Portugal onto four points in Group B, while Morocco have been eliminated from the competition with their second defeat in Russia.
As for Morocco, head coach Herve Renard has made three changes to the team that lost 1-0 to Iran, with Manuel da Costa, Nabil Dirar and Khalid Boutaib taking the places of Romain Saiss, Amine Harit and Ayoub El Kaabi.
Boutaib had the first half-chance of the match in the second minute, but Morocco's number 13 could only flick his header wide of Rui Patricio's post.
Portugal made the breakthrough in the fourth minute, however, when Ronaldo headed a Joao Moutinho cross into the back of the net from close range to score his fourth goal of the tournament thus far.
Ronaldo had another half-chance in the ninth minute following good work from Portugal left-back Raphael Guerreiro, but the Real Madrid forward dragged his attempt wide of the post.
Morocco had an opportunity of their own in the 12th minute when Medhi Benatia met a corner from the right, but Patricio was on hand to make a smart save.
Hakim Ziyech also tested the Portugal goalkeeper from distance in the 22nd minute, and Morocco were the team on the front foot as they attempted to level the scores.
Younes Belhanda then headed a corner wide of the Portugal post late in the first period as chances continued to arrive.
Ronaldo fired high and wide of the Morocco crossbar early in the second half, before Belhanda tested the reactions of Patricio down the other end as the match gathered pace once again.
Belhanda came even closer just before the hour when he headed towards the bottom corner, only for Patricio to pull off an outstanding save to keep Portugal ahead.
Benatia then struck over the Portugal crossbar in the 61st minute as Morocco passed up another excellent chance. Ziyech was next to try his luck for the Moroccans as he lifted a free kick over the goal in the 68th minute.
Renard's team continued to dominate the possession as the match entered its final 15 minutes, but Portugal were remaining strong at the back as they closed on their first win of the tournament.
Benatia headed another Morocco free kick wide of the post 10 minutes from time, before Dirar fired over the crossbar from distance shortly after.
Ronaldo had a shout for a penalty in the latter stages when he went down under a challenge from Amrabat, but the referee was not interested. It mattered little in terms of the result, however, as Portugal closed out the final stages to pick up a vital win.
Next up for Portugal is their final group match with Iran on June 25, while Morocco - who came close to a late leveller through Ziyech and Benatia - will finish their 2018 World Cup against Spain on the same day.
PORTUGAL (4-4-2): Patricio; Cedric, Pepe, Fonte, Guerreiro; Mario (Bruno Fernandes 60'), Moutinho (A.Silva 89'), Carvalho, B.Silva (Martins 59'); Guedes, Ronaldo
MOROCCO (4-2-3-1): Munir; Diarar, Benatia, Da Costa, Hakimi; El Ahmadi (Fajr 86'), Boussoufa; N.Amrabat, Belhanda (Carcela 75'), Ziyech; Boutaib (El Kaabi 70')