David Cameron's legacy as Prime Minister will be as the man who took the UK to the "brink of being taken out of the European Union", Angus Robertson has told him.

The SNP's leader in Westminster wished Mr Cameron well as the premier prepares to formally leave Downing Street.

But Mr Robertson then blasted Mr Cameron and the Government for trying to take Scotland out of the EU "against the wishes of Scottish voters".

READ MORE: "I was the future once": David Cameron signs off as British Prime Minister

Speaking during Prime Minister's Questions, he said: "Not withstanding our differences I genuinely extend my best personal wishes to the Prime Minister and to his family. I wish them all the best.

"However, the Prime Minister's legacy will undoubtedly be that he has taken us to the brink of being taken out of the European Union so we will not be applauding his premiership on these benches.

"What advice has he given his successor on taking Scotland out of the EU against the wishes of Scottish voters?"

Mr Cameron praised Theresa May, who will take over as PM, as a "brilliant negotiator" before telling the House that his advice to her is that the UK should be "as close to the European Union as we can be for the benefits of trade, of cooperation and of security".

"The Channel will not get any wider once we leave the European Union and that is the relationship we should seek," he said.

"That will be good for the United Kingdom and good for Scotland."

Mr Robertson said Mrs May is "very well known" in Scotland because of the planned deportation of the Brain family from the Highlands.

He also pointed to the likelihood that Mrs May's first major Commons vote will be on "imposing" Trident against the wishes of "almost every single MP from Scotland".

He asked: "How does the outgoing prime minister think that all of this will go down in Scotland?"

READ MORE: "I was the future once": David Cameron signs off as British Prime Minister

Mr Cameron said it is right that MPs will vote on Trident and that "many people in Scotland support our nuclear deterrent".

He said: "You ask about the record of this Government when it comes to Scotland, well I'll tell him what it is: 143,000 more people in work in Scotland, massive investment in the renewable industries in Scotland, the two biggest warships ever built in our history built in Scotland, a powerhouse parliament, a referendum that was legal, decisive and fair, and I might add a Scotsman winning Wimbledon twice while I was prime minister."

The SNP's Carol Monaghan (Glasgow North West) also laid in to the legacy Mr Cameron was leaving for Scotland - but her words were nearly drowned out by loud groans from the Conservative benches.

Alluding to the pending Commons vote on renewing Trident, she said: "Between broken vows, Brexit and the likely renewal of weapons of mass destruction on the Clyde, the Prime Minister has done more for Scottish independence than many of us on these benches could ever hope to do."

And referring to Mr Cameron's father, who was born at Blairmore House in Aberdeenshire, she added: "So, as he contemplates a move to Aberdeenshire, could the Prime Minister now make his commitment to Scottish independence official by visiting SNP.org/join?"

But Mr Cameron brushed aside the criticism and said his Government promised a referendum on Scottish independence and delivered it.

He added: "I've talked many times at this despatch box about creating this powerhouse parliament; what I haven't seen is the SNP using any of the powers they have now got."

His riposte was met with loud cheers from his Conservative colleagues, who had packed the Tory benches to watch their outgoing leader deliver his valedictory PMQs.