"Fourteen kilometres separate the coast of Spain -- and therefore Europe -- from those of North Africa but there is an infinitely greater distance in terms of development," Spain's new Socialist Prime Minister Pedro Sanchez said after talks with German Chancellor Angela Merkel.
"Reducing the depth of this abyss of inequality must be one of the main tasks of the European Union."
Faced with a crackdown by Libyan authorities and Italy's hardline approach to immigration, Spain has now become the main destination for people trying to get to Europe from Africa.
Sanchez said he and Merkel agreed to "intensify dialogue and cooperation with countries of origin and transit" of migrants, mainly Morocco.
He said they were in discussion with the European Commission to unlock aid that would allow Morocco to be much more effective in controlling its borders.
This year Spain took in more than 23,500 new arrivals, more than the total number of migrants last year, the UNHCR said earlier this month, compared with 18,500 arrivals in Italy and 16,000 in Greece.
Saturday's meeting in the southern Andalusia region coincided with the entry into force of a deal under which Madrid pledged to take back migrants in Germany who had already been registered in Spain.
It is one of a series of bilateral agreements that Germany is seeking with EU partners, with Merkel under pressure to reduce the number of migrant arrivals to her country.
Berlin still hopes to persuade Italy and Greece to also accept the return of migrants who were registered on their soil before travelling to Germany.