It is a Conservative implosion that has been years in the making. Having seen her Brexit deal defeated three times in parliament, Theresa May finally admitted that “as things stand I can’t see [MPs] accepting it”.

Just days later Tory MPs delivered their own verdict. Only a minority of May’s party – 133 out of 314 – voted in favour of the prime minister’s request for a delay. She was effectively governing on the back of opposition votes.

May has failed, so far, because she could not win around Conservative rebels, mostly hard Brexiters from the European Research Group. A last, desperate promise to quit if MPs backed her deal only reduced rebel numbers to 34, 28 of them linked to the ERG.

The rebellion had been brewing for years. In 2015, after David Cameron won the general election, a group of Conservative MPs resolved to come together to keep the then prime minister true to his referendum pledge.

Their organiser, the energetic backbencher Steve Baker, was able to bring together veteran Eurosceptics such as Bill Cash, John Redwood and Iain Duncan Smith because, according to one friend, “none of them felt threatened by him”.

Facebook Twitter Pinterest Cameron, with his wife Samantha, delivers his resignation speech outside No 10. Photograph: Anadolu Agency/Getty Images

They took over the ERG, a sleepy organisation providing research material on EU issues for all Tory MPs. Two dozen or so members met weekly, shared a WhatsApp group and began to function as a therapy group-cum-caucus, which initially saw itself as “Cameron’s majority”.

Few Conservatives expected Brexit to triumph in the referendum. But the 52% result and May’s elevation to Downing Street changed the picture dramatically.

The prime minister brought some leading Brexiters into government, but few ever believed May, who had supported remain, embraced the cause.

Timeline Six key Brexit moments for Theresa May Show Hide Theresa May is elected Conservative leader and, having backed remain, seeks to burnish her credentials as someone who can unite her party by appointing key leave figures to the cabinet, including Boris Johnson as foreign secretary, Liam Fox as trade secretary and David Davis as Brexit secretary. In her first conference speech, May sets a course for a hard Brexit by vowing 'we are going to be a fully independent, sovereign country' and implies the UK will leave the customs union and the single market. Three months later, she delivers the Lancaster House speech that inked her red lines in permanent marker and left her with little room for manoeuvre. Having decided to call a snap general election in order to garner a majority that would allow her to push her Brexit vision through the Commons, a calamitous campaign results in the Conservatives losing their majority. That left May not only turning to the DUP in order to prop up her government but set the scene for the parliamentary deadlock that was to come. May gathers her warring cabinet at Chequers in a bid to set out a compromise negotiating position that has a chance of finding favour with the EU. But a perceived move towards a softer Brexit provokes an immediate backlash from the right of the party, prompting the resignations of Davis and Johnson from the cabinet and new plotting from ERG members. With her deal having been voted down by a crushing 230 majority when she first brought it before the Commons in January, May tries again with 19 days left until the original Brexit date. She is again humiliated when the deal is beaten by a majority of 149 votes, as the process becomes mired in parliamentary paralysis. After weeks of fruitless talks with Labour over a Brexit compromise, May launches her 'new' Brexit plan, with 10 commitments designed to address cross-party concerns about her withdrawal agreement bill. Cabinet agrees to the plan, but Andrea Leadsom resigns as the leader of the House of Commons. By the end of the week, May has been forced to announce her departure.

Boris Johnson, the face of the leave campaign, was given the job of foreign secretary, but May marginalised him from Brexit policy. Chris Wilkins, a former speech writer for May, said: “She sees him as fundamentally unserious, and for her that is the worst criticism.”

The prime minister later remarked there was no off-the-shelf plan for Brexit. Instead she set about devising policy in the strictest secrecy, barely consulting cabinet colleagues on the most important diplomatic event since the UK joined the European Union 40 years earlier.

Policy was initially delivered via speeches. According to Wilkins, texts were only shared with cabinet members the day before. There was no general discussion at cabinet, where meetings amounted to “two hours of Greg Clark going on about industrial strategy and everybody going home”, according to Katie Perrior, the then director of communications.

Facebook Twitter Pinterest Theresa May delivers her keynote speech at the Conservative party annual conference in Birmingham. Photograph: Christopher Thomond/The Guardian

Before the 2017 election, the line was handed down by a key May adviser, Nick Timothy, and the decision taken to tack to the right. A key speech was May’s first – to the Conservative party conference in 2016 – in which she said the UK would be “a fully independent sovereign country”.

The implication that the UK would leave the single market and probably the customs union came as a surprise. May also promised that article 50, which gave the EU two years’ notice of the UK’s intention to quit, would be triggered by the end of March 2017, intended, Wilkins recalls, to reassure the party’s right wing.

Another speech in January 2017, at Lancaster House, firmed up May’s “red lines”. Her confirmation that the UK would leave the single market and abandon full membership of the customs union was favourably, and repeatedly, cited by Johnson afterwards.

Timeline Six key Brexit moments for Theresa May Show Hide Theresa May is elected Conservative leader and, having backed remain, seeks to burnish her credentials as someone who can unite her party by appointing key leave figures to the cabinet, including Boris Johnson as foreign secretary, Liam Fox as trade secretary and David Davis as Brexit secretary. In her first conference speech, May sets a course for a hard Brexit by vowing 'we are going to be a fully independent, sovereign country' and implies the UK will leave the customs union and the single market. Three months later, she delivers the Lancaster House speech that inked her red lines in permanent marker and left her with little room for manoeuvre. Having decided to call a snap general election in order to garner a majority that would allow her to push her Brexit vision through the Commons, a calamitous campaign results in the Conservatives losing their majority. That left May not only turning to the DUP in order to prop up her government but set the scene for the parliamentary deadlock that was to come. May gathers her warring cabinet at Chequers in a bid to set out a compromise negotiating position that has a chance of finding favour with the EU. But a perceived move towards a softer Brexit provokes an immediate backlash from the right of the party, prompting the resignations of Davis and Johnson from the cabinet and new plotting from ERG members. With her deal having been voted down by a crushing 230 majority when she first brought it before the Commons in January, May tries again with 19 days left until the original Brexit date. She is again humiliated when the deal is beaten by a majority of 149 votes, as the process becomes mired in parliamentary paralysis. After weeks of fruitless talks with Labour over a Brexit compromise, May launches her 'new' Brexit plan, with 10 commitments designed to address cross-party concerns about her withdrawal agreement bill. Cabinet agrees to the plan, but Andrea Leadsom resigns as the leader of the House of Commons. By the end of the week, May has been forced to announce her departure.

Brexit did not feature much during the election, remarkably in hindsight, but the disastrous campaign undermined May’s authority and she lost her majority.

Under pressure from Jeremy Heywood, the then cabinet secretary, to show the EU there was continuity in government, May said she would form an administration with “our friends and allies in the Democratic Unionist party”. Becoming reliant on Northern Ireland’s DUP complicated the picture further.

Eurosceptics argue this was the point at which May fell into the hands of the civil service, relying on Heywood and Oliver Robbins, who transferred to No 10 from the Department for Exiting the European Union led by David Davis. Gradually, on the party’s right, a betrayal narrative emerged.

Downing Street developed a secretive style of negotiations with Brussels. The DUP had demanded access to the negotiating text in the five weeks leading up to the end of the first stage of talks in 2017, then May tried to bounce the party leader, Arlene Foster, going to Brussels on her own to sign off the deal with the European commission president, Jean-Claude Juncker. However, May took a lunchtime call from Foster, who unexpectedly said no to the agreement.

Facebook Twitter Pinterest Arlene Foster at the Orange Order’s annual Battle of the Boyne parade in Fife, Scotland, last year. Photograph: Murdo Macleod/The Guardian

What had emerged was the soon to be infamous “backstop” – initially a promise for Northern Ireland to maintain “full alignment” with the customs union and single market in the absence of a Brexit deal. It was the first of many times May misjudged the limits of her authority.

May returned to Brussels a few days later with a revised commitment to extend the backstop to the whole of the UK. While it brought the DUP on board, who had argued it would otherwise create an invisible customs border down the Irish Sea, it created fresh problems.

Johnson and Michael Gove said they thought it represented the beginnings of a long-term trade deal in which the UK would maintain strong alignment with the EU.

They were temporarily bought off with reassurances from Downing Street that “these were only words” and should not be taken seriously.

Cabinet was called to a summit at Chequers in July 2018 to discuss Britain’s future trade relationship with the EU after Brexit. It was the first substantive discussion on the topic, papers were only sent out the day before, and there was no negotiation.

One minister said they were told amendments could not be proposed because it had all been signed off with the German and French leaders, Angela Merkel and Emmanuel Macron. Downing Street briefed that if ministers wanted to resign they would have to walk to the nearest pub and call a taxi.

Facebook Twitter Pinterest Cabinet members meet at Chequers in Aylesbury. Photograph: 10 Downing Street/Getty Images

By now, May was softening – slightly – her Brexit plans, proposing that the UK sign up to the EU’s “common rule book” for food and goods. It was incremental, but surprisingly unpopular in the meeting, although nobody wanted to walk out there and then.

Davis quit two days later, saying May had “given away too much and too easily” and complaining he had been cut out from a policy developed by Robbins.

Johnson quit as foreign secretary the next day, claiming May’s plan would reduce Britain to the “status of a colony”. Baker also quit as a junior Brexit minister and returned to his role as ERG organiser, forming a double act with the chairman, Jacob Rees-Mogg.

May’s Brexit deal finally arrived in November and although the Chequers proposal did not feature, arguments returned to the backstop.

Another Brexit secretary, Dominic Raab, quit, saying the final version of the backstop was a “very real threat” to the UK’s integrity, as did Esther McVey after a disorderly cabinet meeting in which she twice unsuccessfully called for a vote to be taken.

Meanwhile, the DUP said the final agreement did not match the text of the previous December, and that the detail of the backstop linked Northern Ireland closer to Ireland than Great Britain.

The DUP and the ERG formed a tactical alliance and despite endless talks May could never bring the party around in the following months.

Nigel Dodds, the DUP’s Westminster leader, ultimately declared: “I think it would be actually better staying in the European Union than living under this withdrawal agreement.”

The prime minister tried to power through, but more and more Tory MPs vowed to oppose the deal. May blinked in December and withdrew the necessary approval vote, saying she would have lost by “a substantial margin”. But the unrest within the ERG was such that an ill-timed no confidence vote was submitted.

It was a pyrrhic victory: May won by 200 to 117 but the losing side represented a substantial minority who, under party rules, could not challenge her again for a year. Rightwing Tory MPs suggested May could have been beaten had the vote been held in the new year.

Downing Street took this as a mandate to plough on; insiders believed Johnson and other critics had no realistic solution to the Irish border problem. There was no technology that could eliminate the need for border infrastructure, although the ERG repeatedly pushed the idea.

Facebook Twitter Pinterest A Brexit billboard near the Letterkenny-Strabane border in Ireland. Photograph: Paul Mcerlane/The Guardian

May visited Brussels in December to try, and fail, to get the EU to limit the backstop. It was a poor presentation – May even appealed to EU leaders to show the UK “some Christmas goodwill”.

Remarkably, she claimed afterwards that the EU summit had shown that further clarification and discussion was possible, hours after Juncker complained that her opaque negotiating approach was “nebulous”. The criticism struck a chord, echoing repeated complaints that the prime minister said little and gave away less during private meetings.

It was hoped that Christmas would cool passions, but May’s deal was sunk by 230 votes in January. A complex process emerged in which the Commons held endless votes, making it clear that it agreed on one thing only: to avoid a no-deal Brexit.

Downing Street hoped it could gain some advantage from the mess – signalling to the EU that renegotiation was needed, while warning the ERG that Brexit was at risk if they did not comply.

An extra letter was secured from the EU in March reiterating that the backstop was intended to be temporary, offering Downing Street hope that a slightly revised deal could pass.

This hope was killed off by Geoffrey Cox, the attorney general, who said the legal risk of the UK being trapped in the backstop permanently remained the same, to the acute frustration of No 10. The second Brexit vote failed by 149 votes as the DUP and then the ERG said they could not support it.

Cabinet discipline collapsed, with a split emerging between those opposed to no deal and those against an article 50 extension. Key ministers refused to back May’s line, starting with Clark and the work and pensions secretary, Amber Rudd, who abstained on a no-deal vote.

Something dramatic was needed. May began a bizarre negotiation, primarily with Johnson, and seemed to be edging towards surrendering Downing Street.

At the first of three meetings, Johnson told May “a new approach” was needed in the next phase of negotiations. But May tried to stand her ground, saying she might fight a general election to unlock the crisis, and no deal was done.

By the third meeting, a Chequers summit in March involving half a dozen leading Brexiters including Johnson, Downing Street advisers openly canvassed the idea of May resigning if they voted her deal through.

Jacob, Boris and the so-called coup – what really happened at Chequers? | Hannah Jane Parkinson Read more

An end, of sorts, was in the air, and a few days later an emotional May told the backbench 1922 Committee if the deal was passed, “I am prepared to leave this job earlier than I intended”. Some of the prime minister’s most persistent critics could scarcely hide their delight, revealing how personal some of the opposition had become.

Her offer, finally, split the ERG. But it was not enough. Figures, such as Rees-Mogg, who had been looking for an opportunity to climb down, said they would vote with the government, but there were still enough diehards to sink the deal.

Baker told colleagues minutes after May’s announcement that he was “consumed with a ferocious rage” and he could bulldoze parliament “into the river”. The MP led 28 hard Brexiters into the division lobby against the deal, joining six Tory remainers and the 10-strong DUP to create a majority of 58 to block it.

May declared “we are now reaching the limits of this process” but this did not mean she was quitting. Instead she embarked on a new, if unlikely, plan to talk to the Labour leader, Jeremy Corbyn, about trying to find a way through the Commons because she could no longer rely on her own side.

“It’s a case of Lyndon Johnson’s rule, isn’t it,” one May adviser said ruefully, reflecting on the parliamentary arithmetic. “You have to learn how to count.”

• Next in the series: Heather Stewart on Labour’s Brexit tightrope – to be published Wednesday morning