The only scoring in the match came in the 42nd minute when Morocco's Youssef En-Nesyri took a cross from Yahya Attiyat-Allah and managed to get a header past goalkeeper Diego Costa for the sole goal.
Morocco's fierce defence on Sunday morning AEDT limited Portugal to just three shots on goal.
The team's previous tournament wins include victories over Belgium and Spain.
The match also will be remembered as perhaps the end of major international play for superstar Cristiano Ronaldo, who was removed from Portugal's starting line-up at the start of the round of 16.