French Interior Minister Nicolas Sarkozy agreed the deal with his Moroccan counterpart, Chakib Benmoussa. Mr Sarkozy was in Morocco as part of an African tour, widely seen as a prelude to his presidential bid next year. He has already visited Benin and Mali, where there were street protests over his tough immigration policy, designed to keep out "unskilled" foreigners.
French MPs have already backed Mr Sarkozy's immigration bill but it can only become law after it has been passed by the Senate.
FRENCH IMMIGRATION BILL
Only the qualified get "skills and talents" residency permit
Foreigners only allowed in to work, not live off benefits
Foreign spouses to wait longer for residence cards
Migrants must agree to learn French
Migrants must sign 'contract' respecting French way of life
Scraps law on workers getting citizenship after 10 years
Hundreds of people protested against his visit in Benin on Friday and in Mali on Wednesday. Africa is the biggest source of migrants to France. In Morocco, Mr Sarkozy and Mr Benmoussa agreed to work harder to reduce the flow of people trying to enter Europe through North Africa.
The two men called for "returning immigration to its initial role, as a factor bringing peoples together and as an essential canal for dialogue between civilizations", the French interior ministry said. Mr Sarkozy and Mr Benmoussa also discussed the terror threat in the Sahel-Saharan region and the dismantling of terror groups, a joint statement said.