BRUSSELS (Reuters) - European Union leaders gave Britain six more months to leave the bloc, more than Prime Minister Theresa May says she needs but less than many in the bloc wanted, thanks to fierce resistance from France.

The summit deal in Brussels in the early hours of Thursday meant Britain will not crash out on Friday without a treaty to smooth its passage. But it offers little clarity on when, how or even if Brexit will happen, as May struggles to build support in parliament for withdrawal terms agreed with the EU last year.

With German Chancellor Angela Merkel insisting that Britain would not be forced out and that a chaotic no-deal departure must be avoided if at all possible, there was never any real doubt that May would get an extension.

The drama was about its length and conditions.

French President Emmanuel Macron, reprising a role he took last month when May got a first, two-week delay, pushed leaders into hours of debate over dinner as he fought a largely solo campaign to persuade them not to give the British up to another year.

Summit chair Donald Tusk and others argued that obliging May to accept a much longer deadline than the June 30 date she had sought could help swing pro-Brexit hardliners within her own Conservative party behind her deal, fearing a long delay could see the British public turning against a withdrawal altogether.

But Macron, while irritating some peers who saw his stance as Gallic grandstanding, insisted that letting Britain stay in the Union any longer risked undermining the project of European integration that is one of his main policy goals.

The result was a compromise on the date, with a deadline of Oct. 31, for Britain to leave, deal or no deal -- on condition that May holds an election on May 23 to return British members to a new European Parliament that convenes in July, and that it pledge not to disrupt key EU decision-making before it leaves.

If May fails to win over lawmakers on the treaty or fails to hold an election, Britain will leave with no deal on June 1.

MAY EYES BREXIT SOON

The prime minister was keen to stress that the extension to Oct. 31 -- and several leaders refused to rule out further delays -- did not mean she would not deliver Brexit sooner and before, as she promised her rebellious party, she steps down.

“I know that there is huge frustration from many people that I had to request this extension,” she told reporters, as her team prepared for another round of talks on Thursday with the Labour opposition, to whom May turned for help last week.

“But the choices we now face are stark and the timetable is clear. So we must now press on at pace with our efforts to reach consensus on a deal that is in the national interest,” she added, acknowledging the coming weeks would not be easy.

Slideshow ( 28 images )

Tusk, a former Polish premier who has long tried to keep a door open for Britons to change their minds and stay, said the delay until Halloween gave time for London to ratify May’s deal, tweak elements of the future EU-UK relationship to Labour’s liking -- or give it a chance to “cancel Brexit altogether”.

Merkel, who eased tension at the start of the talks by sharing a joke with May over photographs of them both wearing very similar jackets, stressed a need for calm and order: “We want an orderly exit by Britain,” she said. “And an orderly exit by Britain can be best ensured if we give it some time.”

Slideshow ( 28 images )

FRENCH RESISTANCE

Macron defended his resistance to giving Britain nine months or a year more, saying it was for the “common good”. French officials, pointing to threats by some of May’s pro-Brexit potential successors, spoke of the EU facing “blackmail” by a future British government blocking decisions in Brussels.

“It’s true that the majority was more in favor of a very long extension. But it was not logical in my view, and above all, it was neither good for us, nor for the UK,” said Macron.

French pressure also tightened clauses referring to Britain not disrupting EU affairs if it stays in longer and a reference to a June 20-21 EU summit taking stock of the position again.

May addressed the other 27 for an hour at the start of the summit and failed to convince many, notably Macron, that she truly had a new strategy for securing ratification.

Leaders are exasperated with May’s handling of a tortuous and costly divorce that is a distraction from ensuring the bloc can hold its own against global economic challenges.

Across from the summit venue, the EU executive celebrated its part in funding a global project that produced the first picture of a black hole, prompting no shortage of ironic comments on social media about the juxtaposition.

Blogger Eliot Higgins tweeted: “We’re now more certain about what black holes look like than what Brexit looks like.”