VALENCIA, Spain (Reuters) - Rescued migrants turned away by Italy and Malta arrived at the Spanish port of Valencia on Sunday, ending a grueling Mediterranean odyssey that became symbolic of Europe’s failure to agree on immigration.

Spain swooped to help 629 mainly sub-Saharan Africans on board the ship Aquarius last week after Italy’s new government, asserting its anti-immigrant credentials, refused to let it dock. Spain’s Prime Minister Pedro Sanchez, who took office two weeks ago, took the opportunity to show a more liberal stance.

But the plight of the Aquarius, run by Doctors Without Borders (MSF) and Franco-German charity SOS Mediterranee, highlighted the European Union’s struggle to manage an influx of people fleeing poverty and conflict.

Men, women and children who spent nine days on the Aquarius, after their rescue off the Libyan coast, cheered as they approached Valencia, where they were met by officials in white protective suits and masks, before police processed their information.

The whole group arrived on three separate boats, after some were transferred to two Italian vessels to make the journey safer.

A staff of 2,320, including volunteers, translators and health officials, were waiting on shore. Secretary General of the International Federation of Red Cross and Red Crescent Societies General Elhadj As Sy was also in Valencia.

“This sad odyssey of the people on the Aquarius is another reminder that all people, regardless of their nationality or immigration status, should have access to basic assistance and protection,” Sy said in a statement.

Slideshow ( 9 images )

“No human being is ‘illegal’,” added Sy.

Italy’s rejection of the Aquarius prompted a spat with France, while the issue of immigration has triggered a political row in Germany.

Malta refused to take the boat, saying it had nothing to do with the rescue, which was coordinated by Italy’s coast guard.

“POLITICAL POINT-SCORING”

Karline Kleijer, MSF’s head of emergencies, told a news conference refusing safe port was “shameful”.

“MSF denounces any European government which is choosing political scoring of points above saving lives at sea,” she said.

Slideshow ( 9 images )

“People were threatening to jump into the water (during) the standoff between Italy and Malta, because they were scared and said if we have to die we’d rather die at sea than in Libya.”

No serious illness was reported among the migrants, who included seven pregnant women and 123 minors, but many had suffered burns and fatigue.

All the migrants will get special 45-day humanitarian permits to stay, and asylum requests will be assessed, Chief Inspector of Immigration and Border Police Bernardo Alonso said.

France has offered to take in any passengers who qualify for asylum and want to go there.

Italy’s Interior Minister Matteo Salvini, whose right-wing League party entered government pledging to crack down on flows of migrants which have topped 600,000 over the past five years, tweeted:

“For the first time, a boat that left Libya aiming for Italy docks in a different country: a sign that something is changing, that we are not Europe’s doormat any more.”

Far fewer migrants have arrived in Spain, but the number is rising fast, with more than 1,000 rescued by Spain’s coast guard on Friday and Saturday. A search is underway off the coast of Almeria after four sub-Saharan men rescued by helicopter said their dinghy had been carrying a total 47 people when it sank.

Most Spaniards support the idea of welcoming and helping to integrate refugees, pollsters say. That allowed Sanchez, a socialist, to offer migrant-friendly policies to voters who felt previous governments did not do enough.