Theresa May has written a "letter to the nation" pleading for public support for her Brexit deal as EU leaders endorsed the package in Brussels.

The Prime Minister wrote that the deal "works for every part of our country" and protects the "integrity of our United Kingdom".

But First Minister Nicola Sturgeon slammed the 800-word message as "desperate", with "almost nothing" in it true.

It comes as leaders of the other 27 EU nations meet with May in Brussels to rubber-stamp both the 585-page withdrawal agreement as well as the political declaration on the future relationship, agreed last week.

The summit is only taking place after Spain claimed the UK and EU had given into its demands for concessions over the future of Gibraltar.

The Scottish Government said earlier on Sunday that the deal about to be struck between the UK and EU "does not work for Scotland" that will "cost jobs and hit living standards".

In her letter, May said leaving the EU on March 29, 2019, would mark "a new chapter in our national life" and was an opportunity for "renewal and reconciliation".

May added the deal "will honour the result of the referendum" by allowing the UK to "take back control" of its money, laws and borders.

"It is a deal for a brighter future, which enables us to seize the opportunities that lie ahead," she said, adding that "with Brexit settled" the UK will be able to focus on the economy, NHS, building homes and tackling the "burning injustices" in society.

She promised she would be "campaigning with my heart and soul" to win the vote at Westminster.

May is appealing to the public to build support for her deal while parliamentary arithmetic in the House of Commons currently suggests MPs won't back the package.

It faces widespread opposition from Labour, the Liberal Democrats, from both the pro-Remain and pro-Leave wings of the Tories, and the Democratic Unionist Party (DUP) which props up May's government.

The agreement is also opposed by the SNP, which has long been calling for continued European single market and customs union membership as part of any deal.

Responding to the Prime Minister, Sturgeon tweeted: "I don't say this lightly, but almost nothing in this desperate letter is true.

"This is a bad deal, driven by the PM's self defeating red lines and continual pandering to the right of her own party.

"Parliament should reject it and back a better alternative - (single market and customs union) or #PeoplesVote."

The party's Westminster leader Ian Blackford also took to social media to highlight Scotland's majority support for Remain, adding: "Ultimately independence the only option."

Commenting on the endorsement of the deal by EU leaders, Scottish Brexit secretary Michael Russell said: "The proposed Brexit agreement negotiated by the UK Government does not work for Scotland.

"It takes Scotland out of the European Union against our democratic wishes, it removes us from the single market against our economic interests, and it would put us at a competitive economic disadvantage compared to Northern Ireland.

"The only thing it guarantees is years of damaging uncertainty, which will cost jobs and hit living standards and, by ending freedom of movement, will make it harder to attract the staff we need for our NHS."

"That is why the Scottish Government will now work with others to get a better deal for Scotland within the European Single Market and Customs Union - which is eight times bigger than the UK market alone - and why we support another referendum on EU membership."

But European Commission president Jean-Claude Juncker has poured cold water on the notion the UK could negotiate a better Brexit deal if Westminster rejects this one.

He told the press in Brussels: "This is the deal. It's the best deal possible and the EU will not change its fundamental position when it comes to these issues."

Scottish Conservative interim leader Jackson Carlaw said: "The Prime Minister has shown remarkable tenacity and resilience in securing an agreement with the European Union and deserves congratulations for doing so today.

"As with every negotiation, nobody has got everything they wanted. But this deal does offer the prospect of delivering Brexit and allowing the country to move on.

"Nicola Sturgeon has already come out to pronounce her opposition to the deal. It is hardly a surprise given that she decided to oppose whatever the Prime Minister came back with weeks ago.

"Her plan is to take us back into the CFP, and push through not one, but two more referendums.

"The EU has made clear today: this is the only deal on the table. It will protect jobs, it is backed by business, and it will allow us all to move on."

Scottish Lib Dem leader Willie Rennie commented: "Now we know the deal that the PM thinks is good enough, now is the time for the people to decide whether it actually is good enough.

"This is too important to leave to a bitter, divided Conservative Party. We urgently need a People's Vote."