Morocco were in jubilation as they became the first team in Africa to enter the semifinals of a World Cup tournament.
The hard-fought game was won by a header goal from Youssef En Nesyri just before half-time.
Meanwhile, Portugal struggled to find a way to goal and missed many relevant chances.
Morocco will play France or England in the semifinals next week.