EU leaders are gathering in Brussels

EU leaders are gathering in Brussels on Sunday for a special summit to endorse a deal on Britain's departure from the European Union, as well as an accompanying political declaration on future relations.

Negotiations continued up to the last minute on the package of texts, which will lay out the legal terms for Britain's departure on March 19, 2019, as well as paving the way for negotiations on the future political and trade relationship.

Even after Sunday's expected endorsement by the leaders of the 27 EU states remaining after Brexit, the road ahead is likely to be rocky.

The 585-page withdrawal agreement has drawn fierce criticism from eurosceptics as well as pro-EU politicians in Britain, where it looks likely to fail in an initial vote in parliament slated for mid-December.

In particular, Brexiteers dislike the so-called backstop aimed at preventing the re-emergence of a hard border on the island of Ireland after Northern Ireland leaves the EU along with Britain.

The backstop, which would only apply in the absence of a better solution, foresees some divergent regulatory standards for Northern Ireland and Britain, which critics argue would divide the United Kingdom.

It would also place Britain and the EU in a joint customs territory that London would not be able to unilaterally leave.

On Saturday, Spain and Britain resolved one of the key last-minute sticking points concerning Gibraltar, a British territory on the southern tip of Spain that Madrid also claims sovereignty over.

Despite these issues, British Prime Minister Theresa May has said the agreement is the "best possible deal" for her country.