Scotland’s independence referendum in 2014 was a warning of the ugly division to come under Brexit, says a senior civil servant involved in both votes.

The claim is made in a new documentary, Laura Kuenssberg: State of Chaos, airing on BBC2 tonight.

The three-part series looks at the upheavals in UK politics since the EU referendum of 2016.

In the same episode, Theresa May’s Scottish chief of staff hits out at being “thrown under the bus” after the snap election of 2017 backfired.

And another senior civil servant says Dominic Cummings was “not bothered” if Boris Johnson had to be taken out of Downing Street in handcuffs - as long as the UK left the EU on time.

Kuenssberg’s film charts the fear among MPs as angry protests took place outside parliament for and against Boris Johnson’s attempts to force Brexit through.

READ MORE: Andrew Marr on Scottish Labour leader Anas Sarwar

Amber Russ, a minister at the time, said: “I don’t know a single MP who didn’t get a death threat.”

Kuenssberg observes: “This did not look or feel like Britain.”

From 2012-2019, Philip Rycroft was the lead civil servant in the Cabinet Office advising UK government ministers on the constitution and devolution. He went on to become the permanent secretary for exiting the EU.

As the political temperature rose outside and inside parliament, Mr Rycroft’s mind was cast back to the referendum in Scotland.

“This is what referendums do,” he tells Kuenssberg. “They drive a deep wedge into the political psyche of the country and it is very, very hard to recover from that. We saw that in Scotland.

“Because I’d been so involved in that campaign I sort of knew what was coming and it’s not been pretty.”

READ MORE Scottish economy 'fares better than most of UK'

The series features interviews with ministers including Philip Hammond, Sajid Javid, and Matt Hancock. But it is the sit-downs with former civil servants and aides, many of whom are speaking publicly about events for the first time, that give a sense of what it was like to be “in the room” when history was being made.

Kuenssberg opens the story with Thersa May becoming PM after David Cameron resigned.

Mrs May’s closest aides, Fiona Hill and Nick Timothy, had already made enemies across Westminster and Whitehall for their “fierce” protection of the PM. When their plan to increase May’s Commons majority with an election backfired it was clear who would be blamed.

Hill says: “The whole atmosphere of that campaign can be summed up in one word and that word is cold and grim [sic].”

The results in, Theresa May said Ms Hill had to go.

“She told me that I had to resign, I resigned and that was the end. Although it wasn’t really the end, because I then spent quite a long time being thrown under the bus and having my reputation completely and utterly ruined, without any support from either the party or the government. But that’s politics.”

For more Scottish news and views please subscribe

Another former civil servant, Karen Macnamara, recalls warring with Dominic Cummings after the Supreme Court ruled the prorogation of parliament unlawful.

Cummings said he was “not bothered” if the PM had to be taken away in handcuffs because they had broken the law to leave the EU on time.

Laura Kuenssberg: State of Chaos, 9pm, BBC2, Monday 11 September