Morocco and the EU signed in 2012 a multi-million-euro fishing and agriculture trade agreement.
Morocco's government on Monday warned the European Union that its failure to fully implement an agriculture deal with Rabat would have severe consequences and could spur illegal migration.
The North African nation and the European Union signed in 2012 a multi-million-euro fishing and agriculture trade agreement.
Two years later the deal was quashed by a European court after a challenge from the Polisario Front which seeks independence for the disputed territory of Western Sahara.
But the EU's top court overturned that verdict in December 2016, setting the stage for the reinstatement of the agreement although the ruling did not say so explicitly.
Morocco's agriculture and fisheries ministry said in a statement Monday that the last ruling "in all logic confirms the (2012) trade protocol which must be fully implemented".
Failure to do so would affect "thousands of jobs" both in Morocco and in Europe, said the ministry.
Furthermore it could spur "a new flow of migration" towards Europe and place the continent "at risk".
In addition, it would force Morocco to seek trade deals with other countries.
The ministry said if the deal with the EU was not implemented, Morocco "would have no other choice but to turn to other countries" including Russia, China, India and Japan as well as African and Arab Gulf nations.
The warning comes days after EU leaders held a summit in Malta for talks that also focused on how to deal with a feared upsurge of migrant smuggling, including from Africa.
Although most migrants from sub-Saharan African seeking a new life in Europe have been travelling through chaos-riddled Libya, others have managed in recent years to enter Spain from Morocco.
Spain has two enclaves in North Africa -- Ceuta and Melilla -- surrounded by hi-tech border fences that are regularly stormed by migrants. Many have died tried to climb them, some shot by Moroccan forces.
Other migrants, most of them from sub-Saharan Africa, take to rickety boats to try to cross the narrow stretch of sea between Morocco and Spain's southern tip.
According to the International Organization for Migration, 13,246 migrants arrived in Spain last year, more than 8,100 of whom came by sea.