Morocco is on the exchange list � but the details vary
The DGT includes Morocco in its list of countries with exchange agreements. That leads to a more specific one: which category do you hold and what tests might Spain require to recognize it.
So the exchange should not be treated as a simple yes-or-no answer. The agreement exists, but the real path depends heavily on the type of permit.

Light categories and professional categories follow different routes
The official exchange page states that car, motorcycle, and light-vehicle categories without extra testing use fee 2.3 at 28.87 euros. Truck or bus categories with additional tests use fee 2.1 at 94.05 euros.