Mr Rycroft worked for the Scottish Office from 1989 to 1999, when he moved to the newly-established Scottish Executive. He worked there for a further decade, rising to head the education department, before returning to Whitehall in 2009.

He was part of the new Brexit department when it was set up in 2016, taking over as permanent secretary the following year. He took early retirement on 29 March 2019, the date the UK was originally scheduled to leave the EU.

MPs are locked in dispute over the latest departure date, 31 October, with opposition members passing legislation to block the UK from leaving without a deal while Mr Johnson presses for a snap general election.

Mr Rycroft said the UK was in "unprecedented territory", saying he had "not experienced anything remotely like this in 30 years in public service".

Image copyrightReuters

The veteran civil servant is to give a speech in Edinburgh on Monday evening, where he will suggest that the future of the UK could be at risk if a new approach is not considered.

He told BBC Scotland: "There is fresh pressure on a relationship that was stressed anyway, and we've not even reached the end of the beginning yet. There's a whole lot more stuff to come down the Brexit track which will require intense discourse, dialogue and discussion between the governments of the UK.

"I find it difficult to say at the moment how the existing structures can withstand that sort of pressure.

"Any incoming UK government is going to have to think hard and fast about what the offer is to people in Scotland and Wales and Northern Ireland in terms of engagement in the next stages of the Brexit process, critically to demonstrate that the interests of the people of Scotland, Wales and Northern Ireland will be incorporated in that process and respected.

"Otherwise there is a risk that in leaving one union, this other union founders."

Media playback is unsupported on your device

Media captionBreaking down a big week for Brexit

Mr Rycroft said the UK government may need to "think quite radically" about the links between the nations of the UK if they are to endure.

He suggested that one move would be to "super-charge the existing arrangements", with "Whitehall upping its game on devolution".

However, he said that "given the pressure Brexit will put on the system, that might not be enough", saying a move to a more federal structure for the UK might be needed.

He said: "The UK as a policy is under pressure as never before. Scotland came quite close to deciding to leave the UK, and Brexit has further destabilised that situation. There is clearly a risk that majority opinion in Scotland over time moves to support for independence.

"The UK government has it within its gift to say to people in Scotland, 'look we understand your concerns, we know the key thing you want is your opinion, your interests to be respected in the councils of the land, at the level of the UK, here is an offer that will give you that and will hopefully persuade you to stay in the UK'.

"This needs to be top of mind for this PM and any future PM - if it isn't, they are risking the future of the UK."

Media playback is unsupported on your device

Media captionNicola Sturgeon: "We will seek agreement to the transfer of power that will put the referendum beyond legal challenge."

Scotland's first minister, Nicola Sturgeon, insists she has a "clear democratic mandate" for a second independence referendum, but wants to win an agreement with the UK government to put any vote "beyond legal challenge".

She said Westminster was engulfed in a "political and constitutional emergency", with Mr Johnson plotting an "anti-democratic move" to "shut down parliament" and push through a "catastrophic" no-deal Brexit.

The SNP leader said she was determined to offer Scots a choice on "a better and more hopeful future as an independent country" during the current Holyrood term.

Prime Minister Boris Johnson, meanwhile, has said "the separatists in Scotland drone on and on about breaking up and smashing the oldest and most successful political union" in order to "detract from their appalling domestic record".

He said the SNP's "signature policy" was to "return Scotland to the European Union after Brexit, compete with the euro, the full panoply of EU laws and the surrendering of Scottish fish just when they have been taken back by this country".