British prime minister Boris Johnson has appointed Brandon Lewis as Northern Ireland secretary, his office said, after sacking Julian Smith from the role in a cabinet reshuffle earlier on Thursday.

Mr Lewis had been serving as secretary of state for defence.

Mr Smith became the first casualty of Mr Johnson’s government reshuffle after being unceremoniously dumped as Northern Ireland Secretary.

His departure comes just weeks after brokering the deal which restored the powersharing administration in Stormont.

Mr Smith said it had been “the biggest privilege” to serve the people of Northern Ireland and he was “extremely grateful” to have been given the chance to serve “this amazing part of our country”.

“The warmth & support from people across NI has been incredible,” he said on Twitter. “Thank you so much.”

He tweeted: “In 8 months as Secretary of State, Julian you helped to restore powersharing in Stormont, secured an agreement with us to avoid a hard border, plus marriage equality. You are one of Britain’s finest politicians of our time. Thank you”

Mr Smith was called in to see the prime minister in his Commons office as the reshuffle began. Mr Johnson intends to “promote a generation of talent” in a reshuffle aimed at preparing the Tories for the future.

Also sacked in Mr Johnson’s reshuffle on Thursday morning were business secretary Andrea Leadsom, housing minister Esther McVey, environment secretary Theresa Villiers, education minister Chris Skidmore, and attorney general Geoffrey Cox.

Speculation about Mr Smith’s position centred on the terms of the Stormont deal, amid Tory concerns it could pave the way for prosecutions of British soldiers.

Britain’s Secretary of State for Northern Ireland Julian Smith arrives at Downing Street on Monday. Photograph: Hannah McKay/Reuters But allies of Mr Smith said it was “absolute crap” to suggest that Mr Johnson and Number 10 had not been kept informed of the process and details of the deal.

SDLP leader Colum Eastwood described the decision to sack Mr Smith as a “strategic error”.

“It defies belief that after the successful restoration of power sharing following a three-year collapse, Julian Smith’s reward is a cabinet office P45,” he said in a statement.

“It tells you all you need to know about Boris Johnson’s attitude to the North that he would sack the most successful Secretary of State in a decade. He is at best indifferent.”

DUP leader Arlene Foster praised Mr Smith’s contribution.

She tweeted: “Spoke with @JulianSmithUK a short time ago to thank him for his help in getting devolution restored. We may not have always agreed (we did sometimes) but his dedication to the role was incredible. Best wishes to him and his family. Always welcome in Fermanagh.”