The European Union is to stop the sea patrols that have rescued thousands of refugees and migrants from the central Mediterranean, after Italy’s populist government threatened to veto the entire operation.

Operation Sophia, which has two vessels and five planes and helicopters, was set up in 2015 to prevent loss of life at sea in a year when 3,771 people died or went missing attempting to reach Europe  in rickety boats.

The sea patrol element of the operation will end on 30 September, though air patrols will be stepped up. The mission will also continue training the Libyan coastguard – part of a controversial strategy that critics say leads to people being trapped in Libyan detention centres, where they suffer horrific abuse.

The future of the mission, which was due to expire this Sunday, became tangled up in an argument over which EU country should take in those rescued at sea.

Italy has refused to take in people from search-and-rescue ships since its government came to office last June. The country’s deputy prime minister, Matteo Salvini, has declared Italian waters closed to rescue boats, leaving a series of NGO vessels and their stricken passengers stuck at sea with nowhere to land.

In response, groups of EU member states have formed coalitions of the willing to take rescued migrants once the ship has docked at another port.