The 25-year-old had hoped that a recent change in the regulations would allow him to make the change but FIFA refused his application in September and the Court of Arbitration for Sport (CAS) said on Friday that it had rejected his appeal.
“The case has been dismissed by CAS and the challenged decision has been confirmed,” it said.
FIFA rules bar players from changing national teams once they have played a competitive international, even if they hold dual nationality.
As a result, El Haddadi was tied to Spain after a single appearance for them in a European championship qualifier against Macedonia in September 2014 when he came on as a substitute and played less than 15 minutes.
El Haddadi and the Moroccan federation appealed to CAS before the 2018 World Cup but it was rejected.