The row has triggered global concern about the migrants' plight.
Hungary's radically anti-immigrant prime minister praised Salvini's move.
THE Spanish government is to allow the migrant ship Aquarius to dock in Valencia after both Italy and Malta refused its entry.
He said there was a moral "obligation to help to avoid a humanitarian catastrophe".
The International Organisation for Migration's director general William Lacy Swing hailed Spain's offer.
Since Italy's navy had coordinated the initial rescue effort, and even transferred some of the migrants its own navy had saved to the rescue ship staffed by volunteer aid workers, it was obliged by worldwide law to ensure their safety. He says Malta would send fresh supplies to the Aquarius.
Chancellor Angela Merkel's spokesman, Steffen Seibert, told reporters in Berlin on Monday: "We are concerned about the situation on this ship, the Aquarius, and the German government calls on all involved to do justice to their humanitarian responsibility".
While thanking Spain for their offer of help, the Maltese Prime minister said Italy had broken global rules and that there was a need to sit down with European partners to avoid an incident like this from happening again.
Muscat tweeted his thanks to Sanchez "for agreeing to accept the Aquarius after Italy violated global law and caused an impasse". "This is a European issue".
While Spain's foreign minister said he hoped its gesture of solidarity would help push other European Union members to re-examine migrant policy at a summit later this month, French President Emmanuel Macron criticized Italy's cynicism and irresponsibility for leaving the migrants at sea, while also deflecting criticism for not allowing the ship to dock in France.
But the government of Malta also refused, and as a result the Aquarius was left with no place to dock.
Echoing similar calls by the United Nations and the bloc's biggest member state Germany, Schinas added: "For the commission there is first and foremost a humanitarian imperative, we are talking about people".
"My aim is to guarantee a peaceful life for these youths in Africa and for our children in Italy", he said, using the Twitter hashtag "We are shutting the ports".
"Italy is done bending over backwards and obeying - this time THERE IS SOMEONE WHO SAYS NO", he wrote on Twitter.
MSF Sea said the medical situation of those on board was "stable for now but unnecessary delay to disembarkation in safe port puts vulnerable patients at risk".
The charity added the boat is carrying several critical drowning and hypothermia patients who had to be resuscitated, as well as several with chemical burns caused by being exposed to a toxic mixture of sea water and fuel for a long time.
Malta Prime Minister Joseph Muscat on Sunday evening told his Italian counterpart, Giuseppe Conte, Malta will not allow the ship to disembark.
Paris: Paris on Tuesday defended its decision not to offer safe harbour to the stranded migrant ship Aquarius after local leaders on Corsica proposed opening one of their ports to the vessel.
Italy plans to transfer some migrants crammed aboard a charity boat onto other vessels on Tuesday and then sail them all to Spain, despite appeals from humanitarian groups to let the group land immediately.
Pictures from aboard the Aquarius, which is operated by SOS Mediterranee and Doctors without Borders, showed hundreds of Africans huddled aboard, including a young girl wrapped in a blanket in the arms of a rescue worker.
"Every life is sacred".
He has accused them of working with people-smugglers.