Image copyright PA Image caption The prime minister returned from holiday with a new hairstyle and a shock announcement

Anne McElvoy, senior editor at The Economist, tells the inside story of the general election for BBC Radio 4 - talking to key figures about what really went on behind the scenes.

On Tuesday 18 April, Number 10's key staffers returned from their Easter break to see Theresa May sporting a new hair-do.

That made Chris Brannigan, the government's then head of government relations, pause for thought and wonder what might propel the prime minister to a hairdresser on a holiday weekend.

It was the first sign of a drama that would wake up Westminster. Theresa May had decided to go for broke - and call a quick-fire general election.

But the result, according to one witness was what one Number 10 insider flatly calls, a "terrible election campaign and a dreadful manifesto".

The result was a night of drama on 8 June that saw Labour resurgent from the left, Tory hopes of an increased majority destroyed - and a hung parliament shored up by support from Northern Irish unionists.

The Inside Story of Election 17 on BBC Radio 4 at 20:00 BST.

With producer Adam Bowen, I set out to trace how one of the great pratfalls of election history occurred - and what its implications looks like for an altered political landscape.

This election goes down alongside Edward Heath's "Who governs Britain?" question in February 1974 (Answer, not Mr Heath) - and Clement Attlee's decision to go to the country in 1951 to enhance a tiny majority won twenty months earlier - only to end up losing to the Conservatives and his old foe, Winston Churchill.

Most of all, we wanted to know what it had felt like to watch the main parties' campaigns from the insiders' perspectives - and hear the moments of hope or despair.

We were after the days of unexpected surges in popularity and the ones where butterflies in the stomachs of campaign-hardened politicians portend reversals of fortune. We like the uneasy laughs and hesitations, as much as the frank admissions or boasts.

It's a storytelling approach to politics I had used last year in "How We Voted Brexit" for Radio 4, digesting major events in the immediate aftermath, after the shock but before a received wisdom surrounds the events.

'Oh dear'

It should feel raw: the kind of stories that participants at the heart of our democratic tussles would tell their friends over a drink - and feel free to admit weaknesses, blunders or surprise at their own successes.

The first words as the exit polls rolled in were, "oh dear", Brexit Secretary David Davis tells us with a grimace.

Now there is English understatement at its finest - and contrasted by Chris Brannigan, the suave former head of government relations, who concluded: "We didn't just shoot ourselves in the foot but in both feet and our left hand at the same time."

Image copyright Reuters Image caption Many Conservatives blame their manifesto for the party's ills

How could it go so wrong for Theresa May and see Jeremy Corbyn outperform his party's expectations?

David Davis confirms to us that no one in Cabinet resisted the siren call of an election. The complexities of Brexit negotiations seemed to demand a bigger mandate than the slight overall majority of 2015.

But Katie Perrior, head of communications until she departed on the day the election was called - Downing Street's operation was so fraught with internal rivalries and personality clashes that it would make an entire BBC mini-series - had concerns.

A snap campaign would reveal "some good things and some not so good things (about the PM)", fretted Perrior, "and I worried about that".

'Chill pill'

On the other side of the battle lines, Manuel Cortes, a trade unionist and close friend of Jeremy Corbyn, was fretful that after poor local election results the party "was not ready" for a national vote.

Shadow foreign secretary, Emily Thornberry was comforting MPs who were on the "defensive" - many confiding they did not expect to be back at Westminster on 9 June.

Corbynism had not been successfully road-tested outside a part of the Labour spectrum that had turned away from Blairism. Even the loyal Thornberry found Corbyn at times "pigheaded" to deal with.

Image copyright Reuters Image caption The Labour leader cut a relaxed figure on the campaign trail

Yet on Team Tory, Perrior noted that whereas Corbyn changed the perception of his character, taking the "biggest chill pill" after Labour had learned that being an "angry miserably grumpy old man doesn't work" - the prime minister looked more wooden and remote as the campaign progressed.

The huge own goal was an ill-prepared reform of social care, announced without calculating or explaining the effect on household finances of those most likely to be affected.

It came alongside other issues, like the proposed end to winter fuel payments for the elderly, that "would upset each aspect of our voter base - and people would expect the worst", says David Davis.

As a former home affairs spokesman for the Tories, he also thought that there was an "unreceived wisdom" when it came to the impact of the serious terror attacks during the campaign.

Gaining Momentum

Far from benefiting the incumbent, it "tied the prime minister up in the aftermath" so Labour had a free hit at the government on the impact of cuts in police numbers.

But was it really a Corbyn surge that did it - as the more ardent Jeremy-philes watching him draw crowds across the country believe - or was it an outfit that had been creating effective grass-roots organisation that had withered in the main parties under both the Conservatives and Labour?

We visited Momentum, lodging in a grey trade union building at Euston, where enthusiastic young activists had pumped out social media messaging and a heart-tugging video entitled, "Daddy, why do you hate me?" - mixing the saccharine saga about a tender dad-daughter relationship, with the message that everything has gone wrong since he voted for Theresa May.

Image copyright Reuters Image caption Mr Corbyn drew huge crowds but insiders worried whether it would translate into votes

It was the party's most shared video by young people - and over a million new names applied to register to vote from the start of the campaign. Here, in the words of Chris Brannigan, was an "invisible fighting force that appeared at the last minute".

We wanted to replay a surprise outcome in a critical constituency. So we headed to Canterbury, a Tory seat since 1918, where the incumbent, Sir Julian Brazier lost narrowly to Rosie Duffield, who still sounded pleasantly dazed at finding herself in Parliament, by a margin of 187.

What was the driving factor, I ask Brazier? "The students," he replies ruefully.

Yet perhaps the most surprising aspect of the aftermath of this upset is that Theresa May looks more settled in Downing Street than when we started making the documentary soon after the vote.

The likelihood of a quick second election has receded.

Is it simply, as one of her team suggests, the job no one wants right now or are possible replacements biding their time? Or is she simply a "prisoner of the Conservative Party", as one witness puts it?

"She's better at being a prime minister than at being a campaigner," says David Davis, adding that May is "calmer than I would have been", at the outcome.

Now there's a pugnacious minister and former leadership contender, sounding emollient, ready to take lessons from a bruising race - and understanding of the prime minister's pain. At least for now.