Gavin Williamson’s sudden sacking as defence secretary by the prime minister who had been his mentor marks a precipitous end to a cabinet career that the 42-year-old thought was merely coming to the end of its first chapter.

The defence secretary, fired by Theresa May after leaks from last week’s national security council, had seen himself as a machiavellian figure who had repeatedly protected the prime minister and who intended to act as kingmaker to the next.

As rumours swirled in Westminster about the identity of the leaker of the decision to greenlight the use of Huawei in 5G telecoms networks, the defence secretary was coolly meeting journalists, emphasising his importance in Conservative circles and exuding a belief that he was untouchable.

Gavin Williamson and Theresa May during a Nato summit in Brussels, Belgium. Photograph: Darrin Zammit Lupi/Reuters

Williamson had hoped to position himself as a kingmaker in the forthcoming leadership contest, happily revealing that every candidate was courting him for his organisational skills, imparting gossip about the state of each of the campaigns. The effect was intended to be simple: whoever had Williamson on their side would win.

There was no sign either of concern that he was close to being fired, talking up how helpful he had been to the prime minister in the past, taking the credit for seeing off challenges to her leadership on a couple of occasions.

Last week, Williamson emphatically denied being behind the leak, although further details emerged about what happened at the fateful national security council meeting. It had been deadlocked, with five ministers for allowing the participation of Huawei, including May herself, and five against; the prime minister’s casting vote was decisive.

At the same time, he was preparing to organise a commemoration to mark 50 years of Britain’s nuclear deterrent at Westminster Abbey on Friday. The event was intended as a career highpoint, with Prince William also due to attend.

In his 18 months as defence secretary, Williamson’s approach to the job was often unsubtle – but it was also surprisingly effective. Last summer he was embroiled in an extraordinary row as he demanded an extra £20bn in spending over the next decade.

“I made her – and I can break her,” Williamson was said to have boasted to military chiefs in remarks reported to a Sunday newspaper at the height of the dispute last summer, remarks that he subsequently denied he was behind leaking.

That assertion came days after a sceptical prime minister had asked him to justify Britain’s role as a “tier one” military power. It was another private meeting that leaked. “People have their head in their hands,” one official reportedly said.

None of the lobbying was subtle, but after a summer truce, in which Williamson refreshed his team, the minister got some of what he wanted. Philip Hammond, the chancellor, handed the Ministry of Defence an extra £500m in the budget for the current year, with the spending review yet to come.

His rise, too, was spectacular. First elected as the MP for South Staffordshire in 2010 aged 33, his big break came when he acted as May’s campaign manager in 2016. Despite not having had a full ministerial job before, he was rewarded with the post of chief whip.

Wasting little time in cultivating an image as an enforcer, Williamson kept a pet tarantula – named Cronus after the Greek god who castrated his own father – in his office in the hope of intimidating recalcitrant MPs.

At the Tory party conference, handed the job of being the warm-up act for the prime minister, Williamson regaled the room with his approach to discipline: “I don’t very much believe in the stick, but it’s amazing what can be achieved with a sharpened carrot.”

May trusted him though, and his influence grew after the disastrous 2017 election, which cost her her majority and led to the sacking of her two most trusted advisers, Nick Timothy and Fiona Hill.

Gavin Williamson on ice breaking drills in Norway with the Royal Marines. Photograph: MoD

The then chief whip was a key supporter of May in the aftermath, helping to broker and maintain the relationship with the Democratic Unionist party, which had promised to support her minority government.

Such was Williamson’s importance that it was a surprise when he was promoted to become defence secretary in November 2017 after Michael Fallon quit, although he did not immediately endear himself.

Skinny and far more youthful than the services chiefs around him, he earned the nickname “Private Pike,” a Dad’s Army nickname pinned on him by Treasury advisers which quickly stuck.

Nor did it help that some of his proposals as defence secretary were harebrained: including the suggestion that British forces should pelt Spanish ships with paintballs if they strayed into Gibraltar’s territorial waters.

In February this year, he made an unexpectedly bellicose speech that prompted the Chinese government to cancel a summit meeting with Hammond.

The defence secretary had suggested that a new British aircraft carrier could visit the South China Sea on its maiden voyage, to assert that the UK does not recognise territorial claims made by the east Asian country beyond the internationally recognised 12-mile limit.

Whatever the criticisms, Williamson clearly thought he was impervious. According to the prime minister’s account, he was presented with “compelling evidence” on Wednesday afternoon suggesting he was behind the disclosure to the Daily Telegraph.

Yet after that, he did not let go. He “swore on his children’s life” that he wasn’t behind the Huawei leak – and even claimed it amounted to score-settling between himself and the cabinet secretary, Sir Mark Sedwill.