Spain and Senegal have agreed to promote legal migration to Spain in an attempt to stem an illegal influx.
Most migrants to the Canary Islands are Senegalese
Spanish Foreign Minister Miguel Angel Moratinos signed the accord during a visit to the Senegalese capital Dakar.
The deal would discourage illegal migration and give Spain the opportunity to recruit a significant number of workers, Mr Moratinos said.
More than half of the 26,000 migrants who have reached the Spanish Canary Islands this year come from Senegal.
Mr Moratinos also signed a co-operation deal that will give Senegal up to 15m euros (£10.3m) of Spanish aid annually over five years.
"Immigration must be legal and matched by development aid, technical assistance and the fight against clandestine immigration," he said.
Mr Moratinos announced that Spain will open a recruitment office for workers in Senegal.
"We are going to establish a new mechanism, a kind of window in order to contract directly and legally Senegalese who want to work in Spain," he said.
The Senegalese foreign minister, Cheikh Tidiane Gadio, said he hoped the two countries would establish a satisfactory mechanism of cooperation.
"If we give young people a chance... to present papers to migrate legally to Spain... that could discourage those who fall prey to smugglers and traffickers," he said.
Before visiting Senegal on Tuesday, Mr Moratinos went to Guinea and Gambia where he signed deals to give aid worth 5m euros for each country.
In return, the two West African countries will help repatriate their nationals who have entered Spain illegally.