ROME — Italy’s new populist government, following through on its campaign promise to crack down on immigration, refused to let a rescue boat with more than 600 migrants dock on Sunday and threatened to do the same to other ships on Monday.

The action set off a day of diplomatic confrontation with the European Union and its Mediterranean neighbors, until Spain said Monday afternoon that it would break the deadlock and accept the ship, the Aquarius, which had been at sea under a sweltering sun since Saturday.

But the blocking of the ship made for the first real test of whether Matteo Salvini, the country’s powerful interior minister and the leader of the anti-immigrant League, would keep the hard-line campaign promises to expel hundreds of thousands of migrants and to prevent new arrivals from landing on Italian shores.

He did, and after Spain offered to take the migrants, he declared victory for his government, saying at a news conference at his party’s headquarters that raising his voice had clearly paid off.