Europe migrant crisis: Gruelling EU match ends in a draw
The threat of an Italian veto on all agreement at this EU summit concentrated minds - but they were very tired minds by 04:30 local time (02:30 GMT).
The England vs Belgium football match provided an all too brief respite.
The migration deal may be enough to defuse German Chancellor Angela Merkel's quarrel with her Bavarian CSU allies, who threaten to impose new German border controls. A CSU meeting on Sunday should decide whether her ruling coalition survives.
Mrs Merkel says Greece and Spain have agreed to take back migrants stopped at the German-Austrian border who are proven to have entered their countries first.
Illegal migration is probably Europe's most divisive issue and the marathon talks reflected that.
The still rather vague wording of the deal reveals how domestic politics is skewing EU policy in this area.
The deal appears to balance measures to tackle the Mediterranean arrivals with those to tackle the "secondary" migration of asylum seekers, who register in one country and move to another.
But the pledge to set up safe new migrant screening centres in the EU and transit countries looks very ambitious. The leaders did not specify where they would be, nor how much they would cost.
Greek socialist Prime Minister Alexis Tsipras lamented that the EU was "deeply divided". "It seems we don't share the same values," he said, condemning "chauvinist, nationalist forces".
The numbers arriving in the EU are 95% lower than at their peak in October 2015, the European Council's summit conclusions note.
That is largely due to the EU-Turkey deal reached in March 2016 and EU naval co-operation with the Libyan coastguard.
But the crisis took a dramatic new twist when Italy's new populist government, elected on a promise to get tougher on illegal migrants, threatened to scupper this summit.
Italy's Prime Minister Giuseppe Conte, new to the political game, was gently mocked when he referred to his skills as a lawyer.
Swedish Prime Minister Stefan Lofven cited his experience as a welder and Bulgarian Prime Minister Boyko Borisov added: "I am a firefighter."
French President Emmanuel Macron reportedly worked with Mr Conte to persuade the others to accept new "voluntary controlled centres" in EU countries, which would screen newly-arrived migrants.
So Italy won an EU commitment to ease its burden. More than 600,000 migrants have come ashore in Italy since 2014. Its reception centres and those in Greece are overcrowded and generally squalid.
The word "voluntary" is stressed in a convoluted clause about these new centres. The legalistic language reflects the difficulty of getting 28 nations to agree.
Italy still wants mandatory relocation of migrants across the EU, but the Visegrad Group - the Czech Republic, Slovakia, Hungary and Poland - rejects it. A voluntary arrangement gets round that obstacle.
But the Dublin Regulation, under which the country where a migrant first arrives has to process his/her asylum claim, remains a thorny issue, dividing the EU.
Italy was dissatisfied earlier that the EU was focused only on creating "disembarkation platforms" in North Africa. The "platforms" would screen migrants picked up off North Africa, and the EU still aims to establish them, to break the people-smuggling gangs' business model.
Much uncertainty remains, not least about sending failed asylum seekers back to their countries of origin. The migrant "return" rate is still below 40%.
Far more co-operation with African countries - and aid - will be needed to tackle the deep-rooted poverty driving so many to head for Europe.
An Oxfam statement criticised the summit deal, saying member states "continue to try to offload their responsibilities onto poorer countries outside the EU" and play "political games".
President Macron called the deal a triumph for the EU over "national solutions". It is evidence that thwarting Europe's nationalists is part and parcel of EU efforts to tackle migration.