The measure, which strengthens an existing requirement of a negative PCR test 48 hours before departure, aims to protect the country amid a surge of cases in Europe, the government said in a statement.
Travelers with positive test must be returned at the cost of the airline that brought them into the country, unless they have a permanent residency document, it said.
Passengers visiting Morocco should also have proof of vaccination. The country made the vaccine pass mandatory to access public places after it vaccinated more than 50% of its population.
Morocco has administered more coronavirus vaccine doses than any other African country, inoculating 24.3 million people out of a population of 36 million. It has also started administering booster jabs.
Last Wednesday, the country ended a night curfew aimed at combating COVID-19 that it introduced in March 2020 after a fall in cases from the summer peak.