Cristiano Ronaldo scored his fourth goal in two World Cup matches as Portugal won 1-0 against a Morocco side that created plenty of chances but were eliminated from the tournament.
Morocco made a bright start and threatened inside the opening couple of minutes when Noureddine Amrabat crossed and Hakim Ziyech set up Khalid Boutaib, whose header cleared the bar.
But any optimism that may have been generated was shattered when, after four minutes, Ronaldo scored his fourth goal in two games when Joao Moutinho crossed and Ronaldo, all alone, thundereda header high into the net.
With nine minutes on the clock he was close to doubling his tally, spinning away from a defender before sending a low shot just wide of the far post.
Three minutes later, however, Morocco went close when, from a corner, Manuel da Costa powered in a downward header but Rui Patricio saved.
And when they came forward again soon after the quarter-hour mark, Cedric produced a good block to clear a Nabil Dirar cross.
Ziyach tried a low strike from distance, stopped by Patricio, as Morocco continued to apply pressure.