A group of African migrants who had been stranded off the Maltese coast for eight days are being flown to Spain.
Thousands of migrants attempt to reach Europe each year
The 51 migrants were allowed to disembark at La Valletta on Friday after Madrid agreed to take on most of the group who are mainly from Eritrea.
While Malta said it would take three migrants, the others will be taken in by Spain, Italy and Andorra.
Since January almost 1,000 immigrants have landed on Malta, which has a total population of 400,000.
Spain is also dealing with its own immigration crisis in the Canary Islands, with some 11,000 African migrants arriving on the island chain so far this year.
Malta had initially refused to allow the ship to dock, saying the Africans were rescued outside its territorial waters.
Three of the migrants, a pregnant woman, a mother and a baby, were allowed ashore on Tuesday for medical treatment.
It had said the men, women and children were the responsibility of Spain or Libya since the boat was Spanish and the migrants were picked up in Libya's search-and-rescue zone.
Ten migrants, originally destined for Libya, will now be taken on by the United Nations refugee agency.
Intervention by the EU helped to resolve the crisis.
Malta has received strong criticism from human rights groups for its actions during this crisis, says the BBC's Danny Wood in Madrid.
But Malta, which joined the EU in 2004, says it has no more capacity to deal with illegal immigrants and has been pressing the EU to help.
The European Commission's leading role in resolving the crisis is a sign that the EU is getting serious about helping member states with illegal immigration problems, our correspondent says.
"Europe has finally realised our limits. This has been an example of collaboration and how such a burden can be shared," Malta's Foreign Minister Michael Frendo said.
On Wednesday, a plan to create rapid reaction teams of border guards to deal with European Union immigration crises was unveiled by the European Commission.
Most of the migrants are thought to be from Eritrea
Meanwhile, the Spanish crew which rescued the migrants last Friday have been hailed as heroes in Spain.
"What they did shows the sort of men they are," Pepi Irles, wife of the boat's captain, told reporters.
The Spanish government said it would award the crew a merit medal for saving 51 lives, Reuters news agency reported.
One of the ship's crew members said that after their experience at sea together, the migrants were like his family and he was sad to see them go, our correspondent says.