LISBON, Portugal — Portugal and Morocco signed an agreement Wednesday setting out legal guidelines for Moroccans to live and work in the European Union country, as part of an effort by the two countries to fight illegal migration and human trafficking.

The deal came after fears that undocumented migrants seeking a way into the EU were increasingly targeting Portugal, as boats carrying African migrants from Morocco arrived in recent years on the southern Portuguese coast.

Authorities feared that smugglers were testing Portuguese border controls amid a European crackdown on migrants in the Mediterranean Sea and high fatalities on the sea route between Africa and Spain's Canary Islands.

The Portuguese Foreign Ministry said in a statement that the agreement allows for the recruitment, hiring and immigration of Moroccan workers, ensuring they have the same rights and duties as Portuguese workers.

Portugal is short of workers, especially in construction and farming, and has a low birth rate that threatens the sustainability of its social security system, especially old-age pensions.

___

Follow AP's global migration coverage at https://apnews.com/hub/migration