A rescue ship stranded in the Mediterranean Sea since Sunday is on its way to Spain, where the government has agreed to accept the 630 people on board.
A source close to the Spanish government told CNN that the migrants on board the Aquarius would be given a 15-day permit to stay, during which they would be able to start the process of seeking asylum.
Left to drift for two days in the waters between the Italian and Maltese coasts, the Aquarius search-and-rescue vessel has become the latest symbol of the migration crisis in the Mediterranean.
It all started with a single tweet of just 16 characters and escalated into a diplomatic hot potato that has pitted Europe's countries against one another.
How did we get here?
The Aquarius rescued 630 people while on patrol off the coast of Libya over the weekend, the ship's operators SOS M-diterran-e and Doctors Without Borders (MSF) said. With more than 120 unaccompanied minors and six pregnant women on board, the ship was then directed to travel north in search of a safe harbor by the Italian Maritime Rescue Coordination Center (IMRCC).
The vessel's journey came to an abrupt halt when the Italian Coast Guard told Aquarius to hold its position, the aid groups said.
Matteo Salvini, Italy's new hardline interior minister and leader of the anti-immigration League party, refused to allow it to dock, tweeting the hashtag #chiudiamoiporti ("Close the doors").
He also suggested preventing a second foreign-flagged search-and-rescue vessel, Sea Watch 3, operated by a group of German volunteers and currently positioned off the coast of Libya, from docking.
On Tuesday morning, a US Navy ship recovered 40 survivors and 12 bodies from a shipwreck off the Libyan Coast. Several of the migrants died before they could be rescued by the USNS Trenton, according to a US official and Sea Watch, a non-governmental organization that conducts rescue operations in the Mediterranean. The USis awaiting word as to whether it could transport the survivors to Italy.
Italy has been accused of operating a "double standard" on the issue after an Italian Coast Guard boat carrying 937 rescued migrants was allowed to dock in Catania, Sicily on Wednesday.
"It is unacceptable that people who have literally been picked out of the water, who have seen their friends drowning, still do not get a place of safety," Johannes Bayer, the Sea-Watch chairman, said in a statement Wednesday.
"This is a damning indictment of the European Union's policy on immigration. A dispute about the distribution of asylum seekers must not be carried out at the expense of people in maritime distress," Bayer added.
What is happening now?
Italy dispatched two ships to assist the overcrowded Aquarius on Tuesday afternoon as it began its four-day voyage to Spain after the country's newly assembled government stepped up and offered to take in the survivors.
Around 250 people were transferred to the Italian Navy's Orione and a further 274 to the Coast Guard vessel Dattilo, SOS M-diterran-e said. The Aquarius now has just 106 survivors on board, according to MSF.
All three ships are en route to Valencia, Spain -- a roughly 800-mile journey that is likely to encounter bad weather, according to Jana Ciernioch, spokeswoman from SOS M-diterran-e.
William Lacy Swing, the director general of the United Nations Migration Agency (IOM), tweeted that while he was glad that Spain had stepped forward to defuse the crisis, "I fear a major tragedy if states start refusing to accept rescued migrants as was threatened."
France criticized the Italy for rejecting the Aquarius on Tuesday, Reuters reported.
French government spokesman Benjamin Griveaux quoted President Emmanuel Macron as saying there was "a degree of cynicism and irresponsibility in the Italian government's behavior," the news agency reported. The French remarks drew an angry response from Rome.
The source close to the Spanish government told CNN that, during the process of claiming asylum, they would get the same rights in Spain as Spanish nationals, until their application is processed. That could take up to two years, the source said.
Why did Italy refuse to help?
The Mediterranean remains the world's deadliest migration route and Italy has handled what it considers to be its fair share of migrants trying to reach Europe by boat. The new populist government, refused to grant the survivors entry, demanding that other European nations help deal with the issue.
During Italy's recent election, Salvini had seized on anti-immigration sentiment in the country and pledged to deport 500,000 migrants.
While his rhetoric has softened slightly since he took office, he declared that Italy "cannot be Europe's refugee camp" during a recent visit to Sicily.
But data from the International Organization for Migration (IOM) shows Italy has actually seen a decline of around 77% in sea arrivals in the past year. That drop appears to be a result of a 2017 deal between Italy and Libya in which the southern European country pledged to bolster Libya's coast guard so it could spot departing migrant boats and house migrants attempting the crossing.
Instead, the number of migrants now landing on Spanish shores has escalated. So far, in 2018, that figure has grown drastically from the same period last year. In the first week of June, 561 migrants arrived in Spain by sea routes.
Correction: This article has been updated to clarify that the US Navy carried out the operation that rescued 40 people on Tuesday off the coast of Libya.