European Union leaders placed a bet on Libya's fragile government to help them prevent a new wave of African migrants this spring, offering Tripoli more money and other assistance to beef up its frontier controls.
Meeting in Malta - in the sea lane to Italy where more than 4,500 people drowned last year - the leaders addressed legal and moral concerns about having Libyan coastguards force people ashore by pledging to improve conditions in migrant camps there.
"If the situation stays as is now, in a few weeks we will have a humanitarian crisis and people will start pointing fingers, saying Europe has done nothing," said Joseph Muscat, the prime minister of Malta, which currently holds the presidency of the bloc.
"With this agreement... there is one first decent shot in trying to get a proper management of migration flows across the central Mediterranean."
Aid groups, however, accused the EU, of abandoning humanitarian values and misrepresenting conditions in Libya, where the UN-backed government of Fayez al-Seraj has only a shaky and partial hold on the sprawling desert nation.
Medecins Sans Frontieres, which works on the ground, said the summit proved EU leaders were "delusional" about Libya.
"Today was not about saving lives; it's clear that the EU is ready to sacrifice thousands of vulnerable men, women and children in order to stop them reaching European shores."
The chaos in Libya has thwarted any hope of a quick fix in the way that a controversial EU deal with Turkey a year ago led to a virtual halt to a migrant route to Germany via Greece along which more than a million asylum seekers travelled in 2015.
Earlier, European Council chief Donald Tusk said that the EU still views transatlantic relations as having top priority, despite concerns among some leaders about the Trump administration.
"I have no doubt that for all of us this is still the highest political priority, to protect our relationship with the United States against its enemies," Mr Tusk told reporters at the European Union summit.
Mr Tusk's comments came after he ranked US President Donald Trump with Russian aggression, a more assertive China and Islamic extremism as "threats" facing the bloc, in a letter to EU leaders earlier this week.
Taoiseach Enda Kenny is among the European Union leaders in Malta for the summit.
Maltese Prime Minister Joseph Muscat, the summit's host, said that among EU leaders today "obviously there was some concern on some decisions taken" by Mr Trump.
But he said there was "no sense of anti-Americanism".
German Chancellor Angela Merkel said the best way for Europe to deal with the new administration was to more strongly define its role in the world.
We need your consent to load this rte-player contentWe use rte-player to manage extra content that can set cookies on your device and collect data about your activity. Please review their details and accept them to load the content.Manage Preferences
Meanwhile, Mr Kenny has said that he would "consider", when he was in Washington for the St Patrick's Day celebrations, whether or not to extend an invitation to Mr Trump to Ireland.
Speaking to reporters in Malta, Mr Kenny said he was "no stranger to controversy" and would consider the issue when he travelled to the US in March.
"I'll consider that when I go to Washington, but I wouldn't be afraid of any out-fall from it. But I'll consider that when I get there."
He said he had been clear that he did not agree with some of the policies of Mr Trump but he looked forward to addressing Mr Trump directly, as well as the US Vice-President Mike Pence, and House Speaker Paul Ryan.
"We have lots of things to talk about."
Mr Kenny said there was a strong consensus among EU leaders that they had to engage with the new US administration.
Asked if he would support a move to block the appointment of Ted Malloch, tipped as Mr Trump's next American ambassador to the EU, Mr Kenny said it was a matter for the US administration.
"Whoever it is he's the nominee from America, and we have to deal with that."
Mr Malloch has been widely criticised for likening the EU to the Soviet Union and predicting the collapse of the euro.