Stephen Flynn has been elected as the new leader of the SNP at Westminster, replacing the outgoing Ian Blackford.

The Aberdeen South MP defeated Alison Thewliss for the top job at the party’s AGM on Tuesday and will face Rishi Sunak at Prime Minister’s Questions less than 24 hours later.

Mr Flynn’s deputy will be Paisley and Renfrewshire South MP Mhairi Black – who takes over from Kirsten Oswald.

SNP leader Nicola Sturgeon described the pair as a “formidable team”.

The contest was triggered by Mr Blackford’s resignation last week, with the former leader moving into a role as the SNP’s ambassador to business.

Speaking after the announcement of his win on Tuesday, Mr Flynn said: “It’s an honour to be elected to lead the SNP’s strong and talented team of MPs during such a crucial period for Scotland.

“Under my leadership, SNP MPs will be relentlessly focused on standing up for Scotland’s interests and our democratic right to decide our future in an independence referendum.

“Families across Scotland are paying a devastating price under Westminster control, with Brexit, austerity cuts and the Tory cost-of- living crisis hammering household budgets.

“SNP MPs will work harder than ever to hold the Tory government to account – and make the case that independence is the essential route to safety, fairness and prosperity for Scotland.”

The new leader also paid tribute to Ms Thewliss, her deputy pick Stuart McDonald and the outgoing leadership.

Ms Black said she was “delighted to have been elected”, adding: “Westminster is failing Scotland.

“With the Tories and Labour Party both wedded to Brexit, austerity cuts and democracy denial, it’s clearer than ever that independence is the only way to escape the damage of Westminster control and get Scotland back on the path to prosperity.”

Mr Flynn’s ascendancy to the top job comes in the weeks after reports of a coup attempt against Mr Blackford, which were eventually quashed by the Aberdeen South MP tweeting that he was not seeking the position.

Elected in 2019, the former Aberdeen City councillor succeeded Ross Thomson in his seat after he declined to stand again for parliament.

Taking to Twitter in the minutes after the result was announced, the First Minister said: “Congratulations to new @theSNP Westminster leader @StephenFlynnSNP and deputy leader @MhairiBlack – a truly formidable team.

“Looking forward to working with them both.”

While defeated leadership candidate Ms Thewliss congratulated the new leadership team, saying: “Congratulations to @StephenFlynnSNP and @MhairiBlack, and my thanks to all who have been so lovely and supportive – especially my running mate @Stuart_McDonald.”

Both the Scottish Tories and Scottish Lib Dems said Mr Flynn’s victory over Ms Thewliss – reportedly the preferred candidate of the First Minister – showed that the SNP leader was losing sway in the party.