“What about if I stand?”

These were the tentative words, volunteered by a rebellious 66-year-old veteran of the Labour backbenches, that kicked off Britain’s unlikely summer revolution.

It was the end of May. The Labour party was still digesting its crushing defeat, and a group of leftwing Labour MPs had gathered in a small room inside Westminster to discuss the names of potential candidates to represent the left in the leadership election triggered by Ed Miliband’s abrupt resignation. A handful of “establishment” candidates from Miliband’s shadow cabinet had already announced themselves, including Chuka Umunna, Andy Burnham, Liz Kendall and Yvette Cooper – and the leftwingers were looking for someone to carry their standard in the race.

Among those crammed into room W3, which looks out on a statue of Oliver Cromwell, the man regarded by Leon Trotsky as England’s only true revolutionary – were veteran figures from Labour’s Socialist Campaign Group such as John McDonnell and Diane Abbott, who had stood, or tried to stand, without much success in previous leadership contests, and a handful of younger MPs, such as Cat Smith and Clive Lewis, newly elected and still navigating their way around parliament. But it was Jeremy Corbyn, the Islington North MP, who first entered the Commons in 1983, who finally put his own name forward after the group had raised and dismissed a series of other contenders.

“There was a silence around the room,” recalled Clive Lewis, the new MP for Norwich South. “There were some people, for a variety of reasons, who weren’t keen on it – some, I think, because they were worried about what would happen to Jeremy.” As the room pondered the wisdom of backing a candidate who had never come near the front benches during his three decades in parliament, the meeting broke up inconclusively.

Over the following days, an intense debate ensued over the merits of various candidates, and the risks that the Labour left could be decisively crushed by the likes of Kendall or Burnham. “There was a bit of a split,” Lewis recalled, “between those who thought that if we stand and get drubbed and lose, it will basically mean the right of the party would say: ‘Get back into your box – you’ve had your say, you’re finished, go away, you came last. You got Ed in, we lost the election, now you’ve come last’ – that was the fear.” Even among those who felt the left should put up a candidate, many hoped that someone other than Corbyn might stand.

Some had pinned their hopes on Ian Lavery, the former president of the National Union of Mineworkers who chairs the Trade Union Group of Labour MPs. But he said he would not be standing and endorsed Andy Burnham. Lisa Nandy, the young MP for Wigan – and granddaughter of the late Liberal peer Lord Byers – would have been a natural candidate, as a figure of the party’s “soft left”. But Nandy was on maternity leave, and had in any case ruled out standing for the leadership a year earlier, when supporters had urged her to consider putting her name forward if Miliband lost the election.

Jon Trickett, the jovial but high-minded MP for Hemsworth in West Yorkshire – a former aide to Gordon Brown and a leading thinker in the left-of-centre Compass group – had also been encouraged to stand. Trickett had been so disillusioned by Labour’s defeat, and the slate of establishment candidates, that he and Guardian columnist Owen Jones contemplated launching a “Not the Labour Leadership” tour to rally the insurgent mood on the Labour left – before throwing their support behind Corbyn.

When the group of leftwingers met again in Westminster in early June – with the close of nominations less than two weeks away, leaving precious little time to gather the 35 MPs’ signatures required to make the ballot – concerns were again aired about whether the left might consign itself to irrelevance within the party if its chosen candidate fared poorly. But the prevailing view, voiced by Clive Lewis, was that a failure to field a candidate would make the left look weak. “I’ll stand if I’ve got your support,” Corbyn told the meeting, according to one attendee. “The people in the room went, ‘OK, if you’re going to do it, we’ll back you,’” Lewis said.

“It kind of fell to Jeremy,” said Cat Smith, the newly elected MP for Lancaster and Fleetwood, who had worked for Corbyn for six years before standing for parliament. Lewis and Smith left the room and headed to the House of Commons terrace, overlooking the Thames, to begin canvassing support for Corbyn – who announced his candidacy in an exclusive interview with his local newspaper, the Islington Tribune.

At that time, nobody in Corbyn’s fledgling campaign – including the candidate himself – would have believed that he would go on to win the leadership contest by a huge majority three months later. Their most pressing concern at the start of June was getting him on the ballot, and then trying not to finish last. But the man dismissed by many as an irrelevant loner on the political margins would soon deliver what the former lord chancellor Lord Falconer described this week as “an earthquake”.

The tectonic plates took some time to shift, however. The Corbyn campaign started out with the modest ambition of promoting a debate that might move an established candidate such as Andy Burnham to the left. In their wildest dreams the Corbyn team thought they might manage a respectable third place.

The summer of 2015 will be remembered as a moment when something wholly unexpected happened in British politics – and a 115-year-old political party was transformed in three short months.

It is a story of inexperienced young insurgents and veteran leftwingers, who had long since resigned themselves to careers in the political wilderness, realising suddenly and ecstatically that they had a chance to capitalise on years of pent-up frustration with the direction the party had moved. It is a story of how a new and untested electoral system – originally intended to diminish the power of trade union votes – was cannily exploited to bring hundreds of thousands of new members and supporters into the Labour party and shift it sharply leftwards.

Above all, it is a story of the decline of New Labour, a once-triumphant movement whose leaders and ideas had fallen out of fashion. This was a contest rich with factional squabbling, individual errors and missteps, and rising panic among the establishment – but its greatest theme was the failure of Labour’s elite to realise that the party’s base, after five years of opposition, would respond to electoral defeat with defiance.

Jeremy Corbyn addresses a rally in Cambridge during Labour’s leadership campaign. Photograph: Rob Stothard/Getty Images

The battle for the soul of the party began within hours of the disastrous general election exit poll on the night of 7 May, as aides tried to persuade Ed Miliband to remain as Labour leader at least until Christmas to oversee the rigorous postmortem that would need to follow his painful defeat – arguing that the party was in no state to choose a successor right away. Among those who urged Miliband to stay were his former parliamentary aide Jon Trickett, two of his top strategists, Tom Baldwin and Spencer Livermore, and Lord Falconer.

But as an exhausted and distressed Miliband sat with his advisers on the morning after the election, in a party headquarters smelling of stale beer and despair, he made it clear that he could not face another prime minister’s questions – a decision strongly supported by Justine Thornton, his wife. “I want my Ed back,” she said that morning. So it was inevitable a leadership contest would be launched straight away, and conducted under an untested system, introduced by Miliband in 2014, which vastly expanded the number of potential voters by allowing “registered supporters” to sign up for only £3.

The first two moves in the contest came two days later, in a makeshift television studio on a small patch of grass behind Westminster Abbey – set up by the BBC, which had expected to use it for live coverage of coalition negotiations. Chuka Umunna, the highly polished shadow business secretary, was first out of the gate. In an interview with Andrew Marr, Umunna declared the shadow cabinet should take collective responsibility for the defeat; echoing a column he had published in the Observer that morning, he lamented that Labour had given “the impression at times that we weren’t with the wealth creators”. An hour later, Liz Kendall launched her own campaign on the same channel with a similar critique of the failed campaign, telling viewers that Labour had seemed like “the moaning man in the pub”. (One incensed Miliband supporter complained that “Chuka and Liz were literally stepping over Ed’s twitching corpse in the studios.”)

At the start, it looked like the stage was set for a contest whose script could have been written from the Mayfair offices of Tony Blair Associates: Labour had strayed too far leftwards from the formula that had won it three consecutive elections. In hindsight, there were early signs of danger for this strategy. At the end of his appearance on the Andrew Marr Show, Umunna found himself seated next to Lord Mandelson, who had used his own appearance to bury Miliband’s campaign as “a terrible mistake”. In a party still struggling to come to terms with Blair’s legacy, the optics for Umunna were not good; it looked like he was being annointed by one of New Labour’s main architects.

Trickett believes these initial moves were deeply misconceived. “Whilst the party membership were still attempting to come to terms with what had happened, they heard leading members already on the airwaves in highly critical terms talking about manifold failures. I believe that this helped to fuel the search among many ordinary members for a candidate who stood outside the Westminster bubble.”

The day had started badly for Umunna, who had showed up for his interview, accompanied by his partner, Alice Sullivan, only to discover it was not at the usual studio. Umunna and Sullivan, an employment lawyer, had to walk to the makeshift studios in Westminster, trailed by a gaggle of press photographers. The pictures of the couple walking hand-in-hand across College Green unleashed a frenzy of media attention on Umunna’s partner, which helped convince him to withdraw his nascent leadership bid five days later. He concluded he was not ready intellectually and did not want to tolerate further press intrusion into his private life. But he also found that he had less support than expected – partly as a consequence of his perceived remoteness. “He is a nice guy,” one MP recalled, “but in the last parliament, you could get a meeting with Vince Cable, but you could not get a fucking meeting with Chuka.”

On 20 May, another Labour moderniser and would-be leader, the historian and shadow education secretary Tristram Hunt, also dropped out, after concluding he, too, did not have the required support among MPs. Wherever he went to canvass, he found Liz Kendall had got there first – and he reasoned that to have had a chance, he would have needed to spend less time writing history books and more hours sharing pints on the Commons terrace.

With MPs returning to Westminster, many without desks, party members started to cast a weary eye over the remaining candidates. Andy Burnham, the shadow health secretary and conference darling, had thrown his hat in the ring, and knew he would need rapidly to build a broad base of support, including with the unions. One of the first people Burnham contacted was Michael Dugher, the MP for Barnsley East and an old ally of Ed Balls and Gordon Brown. Dugher is, by reputation, a fixer on the right of the party, but he is also a persuasive communicator with an instinctive feel for Labour politics. Burnham, like Ed Miliband in 2010, understood the importance of getting MPs to commit early, and was working the phones, urging Dugher to be his campaign manager. After a conversation with Cooper that left him underwhelmed, Dugher plumped for Burnham.

Dugher immediately spotted a potential problem: “We were the frontrunner,” he said. “If you analyse the races in recent years, the insurgent wins. That’s what Ed Miliband was. That is what David Cameron was. The insurgency thing terrified us and we had to brandish the change. It became our slogan: ‘Be part of the change’.”

At the start, Burnham and Dugher were most concerned about Liz Kendall, “since absolutely, self-evidently, she was a change candidate”, Dugher said. “But we thought her offer would be quite narrow.” Others in the Burnham camp thought that Kendall would be tripped up by the ardent devotion to Blair among her followers, many of whom belonged to Progress, a New Labour pressure group that argues the party must champion what it calls the aspirational classes to win elections. “John Lennon had that line, ‘Jesus Christ was alright, but his disciples were thick and ordinary’,” one member of Burnham’s team quipped. “Some of the people around [Kendall] were verging on the sectarian.”

However, Kendall had started to assemble a strong campaign staff, including Matthew Doyle, a former press officer of Blair’s, and Mark Ferguson, the former editor of LabourList, who had a keen understanding of the party’s grassroots. Her real problem, it soon appeared, was her economic platform: when her campaign commissioned private polling from YouGov about party members’ views on austerity, cuts in public spending and the importance of reducing the deficit, the results were not promising. “We looked at it and thought, ‘We’re not sure we can win from here’,” one of Kendall’s advisers recalled.

Yvette Cooper was slower to assemble her team, which was led by the shadow defence secretary, Vernon Coaker – one of the most popular MPs in the parliamentary party and a family friend of Cooper and her husband, Ed Balls. After the shock of Balls losing his seat on 7 May, Cooper said she struggled with the transition from being part of a shadow cabinet team to fighting her own leadership campaign. “That first month, every party meeting I felt I needed to lift people up and lift myself up after the disappointment of losing the election,” she recalled. “To be honest, it is not part of my style to stand in front of these big banners with my face on.” Cooper’s initial campaign statements – supporting business, defending child poverty targets, advocating more women in technology – came across as bland and technocratic. A senior Cooper campaign source admitted that the early days of the leadership campaign were difficult. “It was a battle to get traction. The press were coming to us saying we were the soggy compromise candidate, everyone’s second or third preference.”

At the bottom of one of the grandest staircases in the Palace of Westminster – leading down from the members’ lobby of the House of Commons – sit the offices of the parliamentary Labour party (PLP). It was here, as the clock ticked towards the deadline of noon on Monday 15 June, that nervous members of the Corbyn campaign gathered in a last-ditch effort to secure the remainder of the 35 nominations required to get their candidate on the ballot.

Behind an oak-panelled door leading to the PLP offices, Corbyn’s supporters pleaded with any undecided MPs to nominate their man – if only to allow “a real debate” about the future of the party. This message had already persuaded Labour veterans such as Frank Field and Margaret Beckett; the four MPs hoping to become the Labour candidate for London mayor had also nominated Corbyn, with an eye on garnering votes from the left.

As the clock ran down, Corbyn was still short of the magic number. “An hour to go, we were in the high 20s and nowhere near,” his campaign chair, John McDonnell, recalled at the campaign’s final rally some months later. “Then we got 32 and we got to 33 and we had five MPs that had promised us that if we got to 34 they would nominate. It got to 10 seconds and then two of them cracked. I admit I was in tears begging them.”

Corbyn’s loyal former staffer Cat Smith was one of those who had come to beg fellow MPs to put him on the ballot. In the final minutes, Smith spotted her fellow Lancashire MP Gordon Marsden as he approached the nominating table. Standing with McDonnell and Jon Lansman – a veteran Bennite and leader in the Campaign for Labour Party Democracy – Smith pleaded with Marsden: “Give us a contest, give us a chance, let us have a debate.”

Marsden was one of a handful of MPs who ensured that, as Big Ben struck 12, Corbyn made it on to the ballot paper. The summer revolution had finally been launched – yards from the room where Oliver Cromwell had signed the death warrant for King Charles I in 1649. “We did it, we did it, we did it,” Corbyn’s son Seb texted to friends. Marsden immediately tweeted that he would be supporting Cooper, and had only nominated Corbyn to ensure a “broad contest”.

Labour grandees, who took another month to wake up to the threat posed by Corbyn, were caught off guard. But John McTernan, Tony Blair’s former political secretary, was quick to spot the danger, calling the MPs who opposed Corbyn but nominated him anyway “morons”. Margaret Beckett, the foreign secretary who served as interim leader after John Smith died in 1994, now agrees: she said her decision to support Corbyn’s nomination was “one of the biggest political mistakes I’ve ever made”.

Corbyn’s success was met with dismay in the other camps, who knew immediately that his entry would shift the contest to the left. This would leave Andy Burnham, for one, dangerously exposed. Months later, one leading figure in a rival campaign could barely control their rage: “To have [the close of nominations] at 12 o’clock on a Monday – we must have been on fucking crack cocaine. You can’t get to anyone, so people were wandering in after a weekend of spending time with their bloody constituency secretary or their leftwing wife, they just fucking wander off the train and hadn’t even had a cup of tea in the tea room by 12 o’clock on a Monday. They go straight down to the PLP office and do something stupid. The people that are around on a Monday morning are the London lot – and for fuck’s sake, it’s the home of the left, it’s all the fucking mayoral candidates and deputy leader candidates.”

To have the close of nominations at 12 o’clock on a Monday – we must have been on crack cocaine

At that moment, the Corbyn campaign had a simpler ambition: to avoid “being ground into the dirt” and finishing a distant fourth place. As Corbyn walked away from the PLP offices after securing his place on the ballot – still wearing his cycling jacket, with a bike helmet dangling off his arm – he told his close-knit team: “Hey, we’re on.”

“I thought, ‘Yes, now come on – smarten yourself up and get some bloody work done,’” Cat Smith recalled. “I said, ‘We need to get you a tie, we need to get you to the TV studios to start pushing the politics.’” But the Corbyn campaign’s initial meetings, in Portcullis House, had a slightly amateur feel – until wise heads suggested that Simon Fletcher, the unflappable former chief of staff to Ken Livingstone, who had served as Ed Miliband’s link to the trade unions, should be brought on board.

Fletcher put together a campaign team who were given a base at the headquarters of the Transport Salaried Staffs’ Association (TSSA) union in Euston. As the campaign grew, staff worked on laptops wherever they could find space in the office. “It was very threadbare and everybody was piled in together,” one campaign staffer recalled. Despite their unpromising surroundings, the Corbyn camp had the edge on their rivals in two key areas: in the digital domain and in their volunteer base, who worked at the headquarters of the union Unite, in Holborn. Simon Fletcher headed up the leadership team at the TSSA HQ, while Kat Fletcher – no relation – headed up the “super vols”, as she dubbed the volunteers. (Fletcher is so devoted to her flock that when she won a £2,000 bet on Corbyn’s victory she immediately set the money aside to pay for them to stay in Brighton for the Labour conference.)

The digital team’s secret weapon was a soft-spoken young tech expert named Ben Soffa. As the TSSA’s head of digital operations – who happens to be Cat Smith’s partner – Soffa was seconded to the Corbyn campaign by his union to try to give it an edge over the other campaigns, which were thought to have been vastly better prepared. Soffa created an app – using the American political organising software NationBuilder – that allowed volunteers to make calls to potential supporters from their own homes. The app provided information about an individual’s Labour membership, which constituency they lived in and its electoral history. Volunteers would follow a series of questions, with the answers fed back to Soffa’s team through the app.

The data coming back to Soffa showed a clear pattern by the end of June: Corbyn was garnering surprising levels of support from across the party, especially from the so-called “three pounders” – people who had signed up to vote as “registered supporters”. The figures were so good that the Corbyn camp assumed they must be incorrect. “The numbers are amazing, but it must just be that we’re finding all of Jeremy’s core supporters,” Soffa told Smith towards the end of June.

Another coup by the Corbyn camp was the prescient decision to embed the £3 registration process directly into the campaign’s website – ensuring that thousands of people who visited the website were easily able to sign up. “It was just an obvious, natural thing to do,” Soffa recalled – but the other campaigns did not think to do it, an oversight they all now regret.

“The moderates were out-generalled at every step in terms of the process,” a senior figure in a rival campaign recalled. Sometimes, however, the war wounds were self-inflicted.

By July, it was clear to everyone that Corbyn was doing better than expected. He had secured the support of Unite and several other key unions, and the crowds at his rallies were growing. But that momentum would soon be turned into an avalanche – with the help of the party establishment.

After Miliband resigned, the deputy leader, Harriet Harman, once again assumed the leadership – just as she had done in 2010 after Gordon Brown’s defeat. But Harman had been traumatised by the fallout from that earlier stint, when Labour, distracted by its own leadership campaign, failed to mount a defence of its economic record in government, allowing the Tories to spread the story that Brown’s overspending was responsible for the financial crash. The issue haunted Miliband in the latter stages of the 2015 general election, and cropped up in the leadership contest.

The Jeremy Corbyn effect Guardian

Reading the preliminary findings of an inquiry into the Labour defeat – and recalling her own experiences on the doorstep – Harman believed it was essential that Labour not be branded as the party of welfare rather than work. She was determined that she would not allow the mistakes of 2010 to repeat themselves by letting another damaging narrative about Labour to put down deep roots – which meant sending a signal to the electorate that the party was listening to their concerns.

On 6 July, two days before George Osborne’s emergency budget, and with a vote on fresh government cuts to benefits and tax credits looming in a new welfare bill, Harman decided to broach the welfare issue at a thinly attended shadow cabinet meeting. She said the party could not resort to reflex opposition. When Burnham resisted, Harman told him bluntly: “You may have noticed we lost the election.” According to one of the people present, “She was unspeakably rude to him.”

Six days later, Harman hurled a grenade into the leadership contest. Speaking on the BBC’s Sunday Politics programme, she announced: “We’re not going to be voting against the welfare bill, we’re not going to be opposing the household benefit cap. We’re going to be understanding about the point about three or more children.”

Burnham supporters were furious. An incandescent member of his camp rang Harman’s aides to complain that the leadership campaign teams had not been informed. “She over-reached herself, basically,” one campaign source said. “It was a political management fuck-up. So just as everyone is arriving on the Corbyn train, the mainstream leaderships are being asked to leave in the opposite direction.”

Burnham responded by calling for “a reasoned amendment” to the welfare bill – setting out the arguments for its inadequacy. (Cooper quickly adopted the same line.) But Corbyn’s response was unequivocal. “I am not willing to vote for policies that will push more children into poverty,” he said in a statement shortly after Harman’s TV appearance. “Families are suffering enough. We shouldn’t play the government’s political games with the welfare system if children are at stake.”

Privately, Cooper had warned Harman that her decision could help hand the contest to Corbyn – as the only candidate not in the shadow cabinet, he was not bound to support the interim leader’s line, and was therefore free to rebel. On 14 July, a difficult meeting of the shadow cabinet took place. Harman began by saying that she was going to take contributions in sequence round the table, rather than choosing speakers from those with their hands raised. She started with Tristram Hunt, who was sitting next to her. He launched into a “long and emotional” speech supporting Harman’s position, according to one person present at the meeting. “If she was retiring at that point, I would have booked Tristram to make that speech. It was a great after-dinner speech, but it went on for hours.” After Hunt had finished, Harman said that Cooper would have to speak next since she needed to leave the meeting early – giving Cooper the opportunity to call for an amendment to the bill. The Burnham camp wanted to take the lead in proposing an amendment, and believed they had been stitched up. “It was obvious [Cooper] was plotting with Harriet, because she then stayed another hour,” one witness said.

Yvette Cooper, Liz Kendall, Andy Burnham and Jeremy Corbyn during a Labour leadership hustings debate on BBC1’s Sunday Politics on 19 July Photograph: Jeff Overs/BBC/PA

When it was Burnham’s turn to speak, he said – to some surprise – that he would support the compromise of tabling a reasoned amendment. But if that amendment failed, as it was certain to do, he argued Labour should vote against the welfare bill. When he left the meeting to attend a Westminster press gallery lunch, he was asked what he would do if the shadow cabinet rejected his view. It was a critical moment, and the flag of rebellion was only half-unfurled. Burnham said he felt uncomfortable about equivocating on the government’s welfare bill, and yet, as a party loyalist, did not want to defy the leader.

It was a half-challenge to Harman’s authority. But Burnham followed Harman’s lead, and abstained from the vote on the welfare bill – admitting later that he had “probably taken a hit” in the campaign for doing so. He has since told colleagues that he would have won the leadership if he had rebelled and quit the shadow cabinet – but this would have exposed a split among his own backers, several of whom did not want to vote against the bill. One Burnham supporter argued that Burnham resigning from the shadow cabinet wouldn’t have made a difference: “If he had voted against the welfare bill, Andy would have looked like a leader of a rebellion, and not a potential prime minister. We could have resigned – but the left would have banked it and moved on to something else, because that is what they do all the fucking time.”

Ironically, the Kendall camp disagreed. “If Andy had resigned from the shadow cabinet and voted against it and taken a good percentage of the supporters with him, he would have been de facto leader of the Labour party that day,” one of her aides said. “It would have been bedlam, but I think it would spiked the Jeremy Corbyn surge and we could have had someone who had voted against the welfare bill, but also a man with a chance of winning a general election.” For her part, Cooper privately told Harman that she would quit the shadow cabinet if there was not a vote against the bill.

In the end, the shadow cabinet was badly fragmented: one faction wanted an amendment and then a vote against the bill; another faction wanted an amendment and then to abstain; and a third group didn’t want an amendment, but wanted to abstain. An amendment was offered and defeated, and when the vote finally came on 20 July, Burnham, Cooper and Kendall abstained. Corbyn – along with a quarter of the parliamentary party – rebelled and voted against.

Two days later, any lingering doubt about the reality of the Corbyn surge evaporated, when a Times YouGov poll found Corbyn in first place – on 53% in a head-to-head with Burnham. On the same day, Corbyn secured his 100th nomination from constituency Labour parties.

The anti-austerity march in London on 20 June. Photograph: Zak Kaczmarek/Getty Images

Watching from the sidelines as Corbyn stormed ahead, Tony Blair had become increasingly anxious that his legacy was being trashed. On the day the YouGov polls were announced, Blair was due to speak at a Progress event at the Institute of Chartered Accountants in the City of London, marking the 21st anniversary of his election as Labour leader. In front of an enthusiastic pro-New Labour crowd, Blair argued that not only was Corbyn incapable of winning a general election but that his approach to politics was deeply misguided. Labour, said Blair, needed to realise that “radical leftism was often quite reactionary ... I wouldn’t want to win on an old fashioned leftist platform.” In answer to a question, Blair said that anyone whose heart lay with Corbyn’s politics should “get a transplant”.

Corbyn refused to fire back – and Clive Lewis recalls his measured response as a crucial turning point for the campaign. “He was being mobbed for a response, and he said: ‘I am not giving a reply to that. I have just put out an economics paper. I am here to discuss policy,’” Lewis said. “It was just the dignity of it. I think many people thought Tony had lowered himself, and from there the campaign went just like that – whoosh. It was massive.”

As Corbyn’s supporters packed out meeting halls around the country throughout July, it looked as though the deferred dream of successive Labour leaders had finally become a reality: a mass movement driven by the grassroots. “I’ve had this feeling for a long time that there are people out there waiting for something to light a spark,” Jon Trickett said. “When Jeremy got on the shortlist, this appetite for change could no longer be ignored or suppressed.”

“The rallies took on a life of their own,” Lewis recalled. He sensed an almost religious fervour at some of the events, including one in his hometown of Norwich in early August. “I’m an atheist and I’m acutely aware of the hard-headedness of politics, I know the religious element won’t win elections, but it can help. Jeremy is Jeremy: he isn’t a rock star politician, he doesn’t have the looks, he doesn’t wear slick clothes, but in a way he is an antihero. He’s genuine, authentic and he just seems to have resonated with people.”

The high point came at a rally on 3 August at the Camden Centre in north London, organised by Grassroots for Jeremy; the meeting was so packed with supporters that Corbyn had to address a crowd on the street outside from the top of a fire engine. The rival camps, however, felt that the strong involvement of the unions in organising the rallies was overlooked amid excitement over the flourishing of a grassroots movement – at some of Corbyn’s biggest rallies, stewards from the Unite union wearing hi-vis vests could be seen helping to direct the crowds. Many figures in the rival campaigns felt that, given Corbyn’s strong union support, it was their candidates who had been the true underdogs.

It was early July when the Corbyn camp began to realise that they were dominating the contest and they needed to produce some chunky policy documents. Perhaps inevitably, the policies they came up with looked a little rushed. In particular, it was felt that Corbyn would have to show real credibility on the economy. Drawing on the ideas of the tax avoidance expert Richard Murphy, Corbyn proposed two big ideas. First, a national investment bank that could fund a new wave of infrastructure projects through a new form of “people’s quantitative easing”. Second, a new crackdown on tax evasion and tax avoidance and uncollected tax debt, which the campaign claimed amounted to as much as £120bn in lost revenue. What the press quickly dubbed Corbynomics provided fodder for the other candidates, who argued Corbyn’s economic programme lacked credibility – but it was far too late for their attacks to have any impact.

Murphy himself disputed an allegation made by Cooper during the campaign that “people’s QE” would provide false hope while stoking inflation and increasing debt. “At this moment, I’m not saying I would actually do a People’s QE programme. I would do a borrowing programme today to fund infrastructure investment. We have low interest rates and so I agree with those people who have said to me, why can’t we borrow? But, I am anticipating a recession, the importing of deflation from China and the risk that we’re going to have a serious downturn – not a 2008 crash but a recession ... The chance we get to 2020 without a recession given all these circumstances is very low. George Osborne is going to discover what it feels like to be running a recession on his watch and created on his patch. I have a very strong feeling he is not going to enjoy that, but that’s what’s going to happen. Therefore the job of responsible opposition is to say this is a problem that it can sort out.”

Kendall had a fair idea by the end of July that the die might have been cast. “It was that initial poll in the Times [on 22 July] when I thought, well, that’s pretty strong,” she said. “But also you could see in the hustings, right from the start, you could see the kind of reactions Jeremy was getting.” By the second week of August, it no longer seemed just possible Corbyn could win – it seemed certain. A second YouGov poll published on 11 August put Corbyn ahead of Burnham by 53% to 21% on the first round. On the same day, the party announced it had received more than 160,000 applications to vote in the final 24 hours before the deadline. That took the total electorate to 610,743. The fervour of the rallies was going to be transformed into votes.

At the end of July, Chuka Umunna rang Burnham to say, “We have been through all the numbers, Corbyn is going to win, and our numbers show you are the only person that can stop him.” Umunna and Michael Dugher discussed whether Burnham could beat Corbyn if Kendall and Cooper pulled out of the race. There was a series of frantic three-way phone calls between leading figures in the camps to discuss the proposal. “Everyone was on holiday,” one source supporting Burnham recalled. “So what would have been a Westminster stitch-up was basically being conducted on premium-rate mobile phone lines from the warmer parts of the European Union.” The Burnham team thought the idea of Kendall and Cooper standing down was worth a go. “Would it have worked? Who knows,” one insider said. “But the truth is that it was our only chance.”

The Burnham team, already tacking to the left with a manifesto designed to appeal to the mood of the party, believed that Cooper was no longer in the race to win, but to come a respectable second behind Corbyn. The Cooper camp disagreed, claiming that their candidate had returned from a family holiday in America refreshed and determined to take aim directly at Corbyn. “We were trying hard to persuade people you didn’t have to choose between your heart and your head,” Cooper said, reflecting on how Corbyn’s entry into the race seemed to have changed the mindset of Labour members. “But the debate became dangerously polarised between choosing your principles or choosing power.”

Burnham’s team were caught between courting the soft Corbyn vote and rubbishing him. “The truth is that every time someone attacked this guy, he went up five points,” Dugher said. “I agreed with some of the sentiment but I thought it was catastrophically unhelpful. I felt you had to engage with Corbyn supporters, not attack them. Just shouting ever louder at his supporters ‘Are you mad?’ was not going to win votes.”

As the race slipped away, finding a way to undermine Corbyn became an obsession for some party grandees. Tony Blair, increasingly nervous that his earlier confidence in Corbyn’s defeat had been misplaced, warned in a Guardian article on 13 August that the party faced annihilation. He told friends: “My worry is that in the mid-90s it was easy for me because the party wanted to win. I don’t think they want to enough yet.”

Gordon Brown, by contrast, was reluctant to wade into the debate, fearing Blair’s interventions had been counterproductive. He told the Burnham team that they needed to understand where Corbyn’s supporters were coming from, rather than criticising them. When he did intervene, finally, on 16 August, it was to deliver a veiled attack on Corbyn without mentioning him by name or endorsing a rival campaign.

As August rolled on, bringing more bad news for the rival campaigns, the panic about a Corbyn victory grew so intense that some of his opponents began to wonder if the election process might be open to legal challenge on the grounds it had been improperly administered. The seeds of this chaos were sown in 2013, when Ed Miliband had asked Lord Collins, the former party general secretary, to broker a new system for election inside the party. “The reforms went wider than first anticipated and changed the whole culture and architecture of the party,” one MP who was involved in those discussions recalled. Collins had envisioned that his new electoral system would first be tested in the context to select Labour’s candidate for London mayor, then expected to take place in early 2016 – he had not expected Miliband would lose an election and then stand down, forcing his untried system to be used for the first time in an election to choose the party’s leader.

In the party’s membership section, based in Newcastle, staff were put on round-the-clock shifts to process the hundreds of thousands of unexpected applications from “three pounders” eager to vote. At party headquarters, what became known as “Operation Ice Pick” – since its intended targets were seen as Trotskyist radicals – attempted to weed out applicants who were not regarded as genuine Labour supporters; according to the party’s own database, as many as 15% of new applications were from people with no previous record of voting for Labour. Lord Falconer was drafted in to advise Harman and the chief whip, Rosie Winterton, on the due diligence being taken to protect the party, an unincorporated association, from a legal challenge. At one point, the party, inundated with new registered supporters, considered extending or delaying the ballot.

Separately, a small group of party grandees proposed the three mainstream candidates should pull out in the hope of invalidating the race. “The idea ran for a few days in the middle of August, but it had no chance of succeeding,” said one of the people involved. “There was no legal justification to stop the contest. The three would have been discredited and if there was a rerun, Corbyn would have walked it.”

Owen Jones behind the scenes with Jeremy Corbyn as he wins the Labour leadership Guardian

Another person who looked at pulling the contest recalled: “Labour headquarters was in a mess with people away on holiday and little cohesion. Harman and Winterton were terrified of being accused of impeding the contest because they feared its outcome. The whole place was like the Keystone Cops.” Instead, Burnham, Cooper and Kendall agreed to write to party headquarters about their concerns, and the story was leaked by the Burnham team to the BBC on 24 August. Harman, who had been wrestling with lawyers through the summer, agreed a meeting could occur to assess how the new electoral system was working, following a hustings due to be held in Stevenage. The candidates were not told the address of the meeting – only that party cars would take them to an undisclosed location.

“It was like a poor man’s James Bond,” one campaign source said. “In the end we had this dreary meeting where Mike Creighton, the party’s head of risk management, basically does a victory lap around the room about how well it’s gone, and how they had caught all the Trots. We were in despair. We had sympathy with the staff. We knew they were totally overwhelmed, but it was obvious there were real problems. We asked how many local parties had done any verification and they later told us 117 parties had done none whatsoever. In the case of Unite, tens of thousands of addresses were sent to the campaign teams just days before the ballot papers went out. But, in the end, we had to decide whether to challenge legally, and we could not.”

One campaign manager now admits that none of this desperate wrangling did any good. “The fact was Jeremy Corbyn did a very good job in turning his campaign into a referendum on politics. His team understood the anti-politics feeling out there – and we looked suited and booted. We looked like the Westminster bubble on stage.”

By the time Corbyn wrapped up his campaign on 8 September in Nuneaton – the marginal seat that had come to symbolise Labour’s failure in the general election – his victory was unstoppable. Cooper still held out hope, on the grounds that preliminary turnout figures had not shown the expected surge of new voters – suggesting that the predicted wave of support for Corbyn might not have materialised. Burnham, meanwhile, suggested until the end that he was the only candidate who could beat Corbyn.

But there was no surprise when Corbyn was announced as the winner at special Labour conference in London on 12 September – only gasps at the scale of his landslide, with large margins among all three categories of voters. Some Labour officials wore black to register their concern, leading to frosty scenes when Corbyn and his team headed to the “green room” after the declaration.

The moment Corbyn became Labour leader Guardian

“When we went into the green room, it wasn’t like ‘Well done’, it was like turning up to a wake,” one member of Corbyn’s team remembered. “People weren’t particularly happy. There were a lot of people with their hands in their pockets fiddling with their change and looking at the shine on their shoes. The atmosphere in the hall was like someone booking a wedding in the same hotel as a funeral.”

The Corbyn team were also surprised to find that the Labour party had not managed to arrange transport for the new leader. “They didn’t even provide a car for him on the day,” a campaign source said. “Jeremy had to provide his own driver.”

Shell-shocked members of the shadow cabinet, some on the verge of tears, gathered together in small groups in the foyer. Umunna and Hunt, who had been identified as potential dissidents, decided to set the tone by declaring that Corbyn’s mandate should be respected. More quietly, however, a small number of other recalcitrants have continued plotting, in the manner of Japanese soldiers who refused to surrender at the end of the second world war.

Corbyn faced a frosty reception at his first meeting of the parliamentary Labour party on 14 September and took two days to form a shadow cabinet that represented a truly broad church. It encompassed Corbyn’s old friend on the left John McDonnell and Tony Blair’s former flatmate Lord Falconer – who cheerfully admitted that he disagreed with his leader on just about every matter of substance. But Corbyn believes that his consensual style, and a forthcoming series of policy reviews, will allow the party to hold together.

Labour now faces an uncertain and possibly turbulent future, in which political differences may not always be expressed in such reasonable terms. But the rival candidate who stood ideologically furthest from Corbyn had warm words for her party’s new leader.

“I think he’s wrong, but he has his analysis and he sticks with it,” said Kendall, who developed a personal rapport with Corbyn during the long campaign – and greeted him with a hug last week after his first appearance at prime minister’s questions. “Put politics to one side here – there was a point during the campaign where Jeremy got a really bad throat, and I saw his wife and his sons and I could see this amazing thing happening ... You get concerned about the person and how it’s going. He didn’t do tactics and neither did I.”

“Jeremy has won a massive overwhelming mandate,” she concluded. “And he has got the right to have the scope to put forward his agenda.” •

• Follow the Long Read on Twitter at @gdnlongread, or sign up to the long read weekly email here