The city of about a million inhabitants was locked down from Monday at noon local time, with public transport suspended, cafes and public spaces closed and movement restricted.
Residents are only allowed to leave their homes "in cases of extreme necessity”, the interior ministry said in a statement, adding that "exceptional authorisation from local authorities” would be required for movement within or beyond the city.
Authorities decided to reimpose the measures to "prevent the spread of the virus” after "new infection clusters” appeared, it said.
The northern city, within sight of the Spanish coast on a clear day, has a vast port and is a key economic hub linking Africa with Europe and beyond.
Morocco had imposed strict nationwide lockdown measures after recording its first COVID-19 cases in March.
It began easing them in June and has since reopened cafes and restaurants, allowing domestic visitors to restart its vital tourism sector.
Its borders remain closed until further notice, except to Moroccans and residents abroad, who will be able to return from Tuesday onwards.
But despite masks being mandatory in public, new localised outbreaks of the disease have forced the shutdown of several cities.
An outbreak at a fish canning factory prompted authorities to lock down Safi, a town of 300,000 on the Atlantic coast, in early July.
The kingdom, with a population of 34 million, has recorded over 15,000 infections including 253 deaths.