Morocco's football federation has lost its case against FIFA to recruit Spain forward Munir El Haddadi before the World Cup.
The Court of Arbitration for Sport dismissed Morocco's appeal against a FIFA ruling that blocked the Barcelona player from transferring allegiance. The verdict was given after a hearing on Monday.
FIFA rules prohibit switching nationality after playing in a competitive match.
El Haddadi, who is of Moroccan descent, played for Spain in a 2016 European Championship qualifier as a 77th-minute substitute in a 5-1 win over Macedonia.
But the 22-year-old El Haddadi is out of favour in Spain and played this season on loan at Alaves.
Morocco and Spain will face each other on June 25 in Kaliningrad. Portugal and Iran are also in Group B.