Both governments refused to allow the ship to dock, before Spain offered it safe port on Monday afternoon "to avoid a humanitarian catastrophe".
The Spanish decision came just hours after the European Union and the United Nations refugee agency had called on Italy and Malta to let the rescue ship in and end the standoff after the two governments traded accusations of not doing enough amid the migrant crisis.
MSF Spain said that while it appreciated the gesture from the Spanish government, it would be unsafe for the boat, which was over capacity and carrying people who needed medical attention, to make the three day trip to Valencia.
The migrants were rescued by SOS Mediterranee's vessel Aquarius in six separate night-time operations in the central Mediterranean on Saturday.
The Council of Europe welcomed Spain's move, with the organization's Commissioner for Human Rights, Dunja Mijatovic, tweeting: "Saving lives at sea is an obligation that states must always uphold".
The Italian government responded with a statement saying "Italy can not accept hypocritical lessons from countries that in the migration field have always preferred to turn their head to the other side", Italian media reported, adding that Rome is considering canceling a summit between Macron and Italian Prime Minister Giuseppe Conte on Friday. We will have to sit down and discuss how to prevent this from happening again.
On Sunday, Italy had refused to allow the vessel to dock in its ports, demanding that Malta should take it in.
"We call on all involved to contribute to a swift resolution so that the people on board the Aquarius may be safely disembarked as soon as possible".
Medicins Sans Frontiers said: "This plan would mean to people already exhausted to spend four more days on the sea".
The French organisation said those brought on board included 123 unaccompanied minors, 11 small children and the seven pregnant women.
SOS Mediterranee spokesperson Mathilde Auvillain said the Aquarius had received orders to head north after a series of sea rescues and was now was awaiting "definitive instructions". "Italy is done bending over backwards and obeying, this time THERE IS SOMEONE WHO SAYS NO", he wrote on Twitter followed by the hashtag #closethedoors. They need to go to the port that is safest and closest. Italy shouldn't have to shoulder the burden by itself, he added, when other European countries aren't doing their fair share.
While Spain's announcement demonstrates humanitarian and moral leadership, the Italian government's actions are a clear reminder of the ways in which political hostility towards refugees and migrants puts lives at risk.
Under EU rules, migrants must apply for asylum in the European country where they first arrive.
SOS Mediterranee said Maltese search-and-rescue authorities were contacted by their Italian counterparts "to find the best solution for the well-being and safety" of the people on the ship.