For hundreds of thousands of desperate migrants, Italy became a safe harbor, a landing place for those crossing the treacherous cobalt blue of the central Mediterranean Sea. But this long-tolerant nation is moving to create a de facto migrant blockade — by striking an odd bargain with Libya, its dysfunctional and war-ravaged neighbor to the south.

Libya is the main launching point for migrants streaming into Europe from across a broad swath of the globe, and whose numbers this year are again surging. Under the plan, Italy would train and equip Libyan guards to scour coasts and deserts to stop, push back and detain migrants before they reach the high seas.

European leaders are counting on the Italian effort in Libya to shut down the last major corridor to the continent for migrants, largely ending a massive influx that began in 2014. But aid groups warn that the plan could come at an overwhelming human cost by trapping untold thousands of migrants in Libya, where the rule of law has all but disappeared since Moammar Gaddafi was toppled nearly six years ago.