MOSCOW, June 20: Cristiano Ronaldo headed Portugal's winner as Morocco became the first team to be knocked out of the World Cup.
Ronaldo's fourth goal of the tournament, from Joao Moutinho's cross, saw him become the leading European goalscorer in international football with 85 goals.
Morocco had several chances to equalise, Rui Patricio's excellent one-handed save denying Younes Belhanda at the Luzhniki Stadium in Moscow.
Superb Ronaldo hat-trick leads Juve into quarter-finals
Portugal move to the top of Group B.
They are one point above Iran that will play against Spain at 11:45 pm on Wednesday.
Belhanda thought he had levelled after meeting a free-kick with his head, but Patricio, who has signed for Premier League newcomers Wolves, produced an instinctive stop.
Medhi Benatia wasted four chances, including a snatched shot in stoppage time, while Belhanda fired straight at Patricio before Morocco's exit from the tournament was confirmed with one match still to play.
The North African nation, beaten 1-0 by Iran in their opening game, are playing at the World Cup for the first time in 20 years.