He was addressing leaders of western Mediterranean countries on the eve of a summit of European Union heads of state, weeks after a boat carrying migrants sank off Italy, killing 366 people.
"I will argue before my European partners that it is necessary to redouble our efforts to prevent tragedies of this nature from happening again," Rajoy said at the forum in Barcelona.
"Control of the European Union's external borders is an effort that must be shared by the whole union, member states and institutions."
Wednesday's forum of foreign ministers in the northeastern Spanish city brought together France, Italy, Malta, Portugal and Spain with five north African states: Algeria, Libya, Morocco, Mauritania and Tunisia.
These countries are among those most affected by migration between northern Africa and southern Europe.
Tens of thousands of migrants fleeing poverty and violence in Africa and the Middle East try to reach EU soil each year.
Many sail in flimsy vessels from Morocco to Spain or from Libya to the Italian island of Lampedusa.
On October 3rd a boat carrying migrants caught fire and sank within sight of the island's shore, killing 366 people. Days later another boat sank off Malta and at least 36 Syrian refugees drowned.
Rajoy also urged "support and cooperation" by countries that migrants come from or pass through.
"The key is to understand that improving living conditions is one factor in solving the tragedy," he said.