We had a very similiar situation.
I have a post about this, but we found that it was substantially cheaper to fly round trip from Spain to Casablanca. By rearranging the order of things, we are saving a substantial amount of money.
As we had just been looking at this, I just checked Iberia and Royal Air Maroq. If you enter flexible dates on Iberia, you will see they have a few 170 euro fares (+tax), round trip from Malaga to Casablanca. They also have a few 190 euro fares (+tax), round trip from Madrid.
It's interesting, because Royal Air Maroq doesn't have a place to enter flexible dates, at least that I could find. I entered our dates on their website, as I don't know yours, and found that Madrid round trip to Casablanca was the same, at 190 euro + tax, but that Malaga round trip to Casablanca is 435 eur + tax.
I hope this helps. Good luck!