Image copyright Getty Images

The Scottish government has demanded to see details of the draft Brexit deal set to be discussed by UK ministers, after a major breakthrough in talks.

Prime Minister Theresa May is to hold a special cabinet meeting on Wednesday to discuss a draft withdrawal agreement.

UK government ministers are also being asked to see Mrs May for one-to-one talks on Tuesday evening.

Scottish External Affairs Secretary Fiona Hyslop said: "We must see this deal, Scotland must not be forgotten".

Scottish Secretary David Mundell said it was "encouraging that there's a potential agreement", but said ministers would "reflect on the detail" ahead of Wednesday's cabinet meeting.

It has been confirmed that a special cabinet meeting will take place at 14:00 on Wednesday as Mrs May seeks backing from ministers.

A cabinet source told the BBC that the document has been agreed at a technical level by officials from both sides after intensive talks.

The future of the border between Northern Ireland and the Republic of Ireland has been the last major outstanding issue to be settled amid disagreements over how to guarantee that there will not be physical checks reintroduced after Brexit.

Image caption Fiona Hyslop told the BBC that "Scotland must not be forgotten"

Speaking at Holyrood after news of the draft agreement broke, Ms Hyslop told the BBC that "Scotland has to see what this deal is".

She said: "Up until today we have not seen this deal, and its important that our views are taken on board.

"If there has been a deal without consulting Scotland, that means Scotland has not been consulted properly by the UK government. We must see this deal and Scotland must not be forgotten."

Scottish Brexit Secretary Mike Russell, who is in London for talks with UK and Welsh government counterparts, added: "It's not good enough, with respect, to just read it in the newspapers. We need to know what is being doing and we need to know it is being done in our name."

And First Minister Nicola Sturgeon said that if any deal fails to command a majority in a vote of MPs, "we should take the opportunity to get better options back on the table".

Mr Mundell told BBC Scotland that it was "encouraging that there's a potential agreement".

He said: "Members of cabinet will have the opportunity to look at that in detail this evening and there'll be a special cabinet meeting tomorrow to reflect on what's in that documentation.

"I'm encouraged, but we need to look at the detail and see what's there and hopefully be in a position to take forward a deal. That's what the government has been looking for all the time, negotiations have worked incredibly hard to get us to this point, but we need to reflect on the detail and then consider it at cabinet tomorrow."

Image copyright PA Image caption Theresa May told the Lord Mayor's banquet that she would not agree a Brexit deal at any cost

Both the UK and EU want to schedule a special summit of European leaders at the end of November to sign off the withdrawal deal and an outline declaration of their future relationship.

Brussels has insisted it would only agree to put the wheels in motion for the summit if agreement can be reached on the issue of the Irish border.

If a deal is agreed with the EU, Mrs May then needs to persuade her party - and the rest of Parliament - to support it in a key Commons vote.

It is understood that Labour leader Jeremy Corbyn, SNP Westminster leader Ian Blackford, Lib Dem leader Vince Cable and others will write to the prime minister demanding that amendments be allowed for the "meaningful vote".

News of the agreement came after late-night talks between the UK and EU in Brussels were said to have ended with "optimism on both sides".

The issue of how to avoid a hard border between Northern Ireland and Ireland has been the biggest headache for negotiators.

In a speech to the Lord Mayor's banquet in London on Monday evening, Mrs May said the "immensely difficult" talks were now "in the endgame".

But amid growing signs of discontent from several cabinet ministers over her handling of the talks, she insisted she would not sign up to a Brexit agreement "at any cost".

Several Tory MPs are unhappy at the expected shape of the deal and have warned it will not get through Parliament.

As well as Leave-supporting Conservative MPs who are worried about the UK being tied to EU rules, some pro-EU Tories also have misgivings.

Please upgrade your browser Your guide to Brexit jargon Enter the word or phrase you are looking for Search

Ms Sturgeon has said her 35 SNP MPs would not support any deal that does not include single market and customs union membership.

And the Scottish Parliament last week voted to formally back calls for another referendum on Brexit to be held.

Mrs May's preferred plan for future relations with the EU after Brexit were agreed at Chequers - the prime minister's country retreat - in July.

Former Brexit secretary David Davis and ex-foreign secretary Boris Johnson resigned from the cabinet in protest at the plans 48 hours later.

Mr Johnson has indicated that he will vote against the draft agreement, describing it as "vassal state stuff".

On Friday, the Remain-supporting Transport Minister Jo Johnson resigned, calling for another referendum and saying what was on offer fell "spectacularly short" of what had been promised.