VALLETTA (Reuters) - Eleven migrants who were stranded on a Spanish fishing boat for more than a week after being rescued off Libya were brought to Malta on Sunday, ending an international stand-off, but Valletta said they would later be taken to Spain.

The vessel was initially refused entry by Italy, Malta and Spain.

The fishing boat, Santa Madre de Loreto, rescued 12 migrants in international waters off the coast of Libya 10 days ago. Spanish NGO Proactiva Open Arms, which has been assisting the boat and migrants aboard, said it would not have been safe if they were returned to Libya.

On Sunday, the migrants were transferred from the Nuestra Madre de Loreto to a Maltese patrol boat, and arrived in Valletta harbor at 1 pm (1200 GMT), Maltese government spokesman Kurt Farrugia said.

However, Farrugia told Reuters that Malta had agreed with Madrid that this was only a temporary solution dictated by “humanitarian reasons”, and they would be taken to Spain in due course.

“Malta had no obligation to take them because they were not picked up in Maltese waters and Malta was not the closest port,” Farrugia said.

A young man among the group was flown to Malta by helicopter on Friday after he fell unconscious due to exhaustion.

The remaining migrants, including two minors, are weak after their ordeal in cramped conditions at sea, said the charity group United4Med.

After offering to take more than 600 migrants rejected by Italy and Malta over the summer, Madrid said that rather than making the long journey to Spain, the boat should head to the nearest safe port.

In Spain, Prime Minister Pedro Sanchez’s Socialists go to the polls on Sunday in a key regional election in Andalusia, the main entry point for migrants making the dangerous sea crossing to Spain.

Immigration has been a major focus of the campaign, while a surging far right is predicted to win its first seats since the 1970s.

“From the beginning, the government has worked to ensure the boat, which is in international waters, goes to a safe and nearby port,” Deputy Prime Minister Carmen Calvo said in a statement on Sunday.

Madrid’s conduct was criticized by Proactiva Open Arms.

“The government now says #Santa Madre de Loreto should head to Malta. Late, wrong and unscrupulous,” the group’s founder Oscar Camps wrote on Twitter on Sunday morning.

“Playing with the security of people who have gone 10 days without news, amid a rough storm, and with one person rescued by helicopter and a high risk for the whole crew,” Camps said.