Youssef En-Nesyri scored the winning goal in the 42nd minute to continue Morocco’s improbable run that has generated an outpouring of pride in the Arab world during the first World Cup to be staged in the Middle East.
The 37-year-old Ronaldo, one of soccer’s greatest players, didn’t start for the second straight game but came on as a substitute in the 51st minute.
The five-time world player of the year is set to finish his career without capturing the World Cup or ever getting to the final.
Morocco will play either France or England in the semifinals.
It is a seminal moment in World Cup history, with an African nation finally advancing to the levels typically only reached by European or South American teams.
Cameroon (1990), Senegal (2002) and Ghana (2010) all reached the quarterfinals but got no further.