Ask ten guidebooks when to visit Morocco and ten of them will say “March to May, or September to November”. That is not wrong, but it flattens a country that contains an Atlantic coast, a 4,000 m mountain range and a chunk of the Sahara.
If the Sahara is your priority, the window is wider than people think: from late September to early May the daytime highs in Merzouga sit between 22 and 30 °C, and the nights are cold enough that the camps hand out extra blankets. July and August are genuinely punishing.
The High Atlas flips the calendar. Imlil and the Toubkal trails are at their best from April to October. Outside that, snow closes the higher passes and the gîtes run on wood stoves.
The coast barely has a season. Essaouira is windy all year — that is why the kitesurfers live there — and Agadir gets around 300 sunny days. Winter on the Atlantic is mild, quiet and about 40 % cheaper.
One practical note: check the Ramadan dates before you book. Travel is completely possible and often more atmospheric, but daytime restaurant options in small towns shrink, and everything shifts to the evening.