BRUSSELS/WARSAW (Reuters) - Britain and the European Union were on the verge of a last-minute Brexit deal on Wednesday but Prime Minister Boris Johnson still has work to do at home to ensure his government and factious parliament approve the plan.

“The basic foundations of this agreement are ready and theoretically we could accept a deal tomorrow,” said European Council President Donald Tusk, who will chair a summit of EU leaders, including Johnson, on Thursday and Friday.

However, Tusk said in comments broadcast by Polish broadcaster TVN 24 that “certain doubts have appeared from the British side”, a reference to Johnson’s need to win over politicians who fear he may have conceded too much.

French President Emmanuel Macron said an agreement was being finalised and hoped it could be approved on Thursday.

“I want to believe an agreement is being finalised and that we will be able to endorse it tomorrow,” Macron said at a news conference with German Chancellor Angela Merkel in Toulouse.

Merkel said she believed slightly more that a deal was possible.

Any approval by the EU of a deal at their summit would be conditional on the British House of Commons backing it at a special sitting on Saturday. A short delay of Britain’s Oct. 31 departure date would follow to polish the detail.

If Johnson fails to nail down the terms of Britain’s exit from the European Union, or fails to get a deal ratified in the UK house, he will almost certainly have to seek a longer extension of the departure date more than three years after the country voted in a referendum to leave.

After another day of technical talks in Brussels, EU officials said an agreement had been reached on customs arrangements for Northern Ireland, ‘level playing field’ provisions on labor and environment standards that the EU has insisted on to ensure fair competition under a new trade deal after Brexit.

That also went for the consent by the Northern Irish assembly renewable every four years to go on aligning the province’s regulations with the EU ones after Brexit.

VAT was the only outstanding element, EU sources said, and a UK government source expected no further movement on Wednesday toward finalizing the deal. The person said that there were issues holding up the deal both at home and with the EU.

While differences over the divorce between the world’s fifth-largest economy and its biggest trading bloc had almost all been resolved, “overall backing from the British government” was still needed to seal an agreement, an EU diplomat said.

The main stumbling block remaining for Johnson appeared to be objections from a small Northern Ireland political party whose votes he must secure to get any deal through parliament.

Slideshow ( 5 images )

WINNING OVER THE DUP

The sticking point in the long-running talks with Brussels over Brexit, which has already been delayed twice, was the border between EU member Ireland and the British province of Northern Ireland.

The conundrum for London was how to prevent the frontier becoming a backdoor into the EU’s single market without erecting controls which could undermine the 1998 peace agreement that ended decades of conflict in the province.

Slideshow ( 5 images )

It eventually proposed that Northern Ireland remain in the UK customs area. However, tariffs would apply on goods crossing from mainland Britain to Northern Ireland if they were deemed to be headed further, to Ireland and the bloc’s single market.

To get a deal that hinges on this through parliament, where he does not have a majority, Johnson will likely need backing from the Democratic Unionist Party (DUP), which says maintaining the United Kingdom’s economic integrity is sacrosanct.

Pro-Brexit lawmakers from Johnson’s governing Conservative Party say they will only back a deal if it has gained the support of the DUP, which fears Northern Ireland could be left behind in the EU’s orbit when Britain leaves.

A central figure in the 2016 referendum who came to power as leader of the Conservative Party in July, Johnson has pledged to take Britain out of the EU on Oct. 31 with or without a deal.

But parliament has passed a law saying Britain cannot leave without one, and Johnson has not explained how he can get around that.

EMERGENCY BREXIT SUMMIT AHEAD?

Irish Prime Minister Leo Varadkar said earlier on Wednesday that if an agreement cannot be reached before the summit, there was still time left to act before the Oct. 31 deadline.

“October 31 is still a few weeks away and there is the possibility of an additional summit before that if we need one ... Although time is running short, I am confident that (Ireland’s) objectives can be met,” he said.

Sterling was on a roller coaster ride through the day as varying reports suggested a deal was nigh or pointed to last-minute hurdles.

Britain’s Brexit minister, Steve Barclay, said he would not accept a delay beyond Oct. 31, even if it was only used to tie up the necessary legal requirements of an agreement. Extension options mulled by the EU range from an additional month to half a year or more.

If necessary, the bloc may hold an emergency summit later in October to either approve a deal, grant an extension or make final preparations for a chaotic split.