At the dawn of 2017, Theresa May dreamt of becoming the first Conservative Prime Minister for 30 years to win a landslide victory. By its close, she was grateful to have survived at all.

2017 was the year that May’s opponents took back control: Labour wiped out her parliamentary majority, the EU forced the UK to accept its divorce terms and MPs defeated the government in the Commons.

And yet the Prime Minister, to many, had earlier appeared politically invincible. The defection of Ukip supporters and Labour Leavers to the Conservatives give the Tories a 20-point poll lead. In February, they became the first governing party to win a by-election (Copeland) since 1982.

Though May was forced by the British judiciary (or “the enemies of the people”) to hold a parliamentary vote on whether to trigger Article 50, she won by a resounding margin (498 to 114 votes). The right hailed the dawn of a new era of Conservative hegemony. "They don't call it the last Labour government for nothing," Philip Hammond quipped in his Spring Budget (which unravelled almost immediately).

To most, the opportunity for May to increase her slight majority of 15 seats appeared too good to resist. It was. On 18 April, having repeatedly vowed not to call a general election, May broke her word. Her decision was acclaimed as a masterstroke by commentators and a chance to “Crush The Saboteurs” by an exuberant Daily Mail. To the Tories’ surprise, Labour MPs overwhelmingly voted for an election.

Most of the parliamentary party, including supporters and opponents of Corbyn, expected Labour’s worst result since 1983 (209 seats) or even 1935 (154 seats). But the leader’s office relished the chance to deliver their message to the country.

Yet the campaign’s early weeks appeared to merely confirm the Tories’ dominance. Rather than falling, the Conservative poll lead rose to new heights (peaking at 24 points). May, who appealed to voters to “strengthen her hand” in the Brexit negotiations, accused the EU of meddling in the election in a ruthlessly presidential address (after details of her ill-fated dinner with Jean-Claude Juncker were leaked). At the local elections, the Tories gained 1,899 seats and Labour became the first opposition to lose ground for three successive years.

But this proved a false dawn for the Conservatives. The seeming inevitability of a Tory victory invited voters to question whether May needed the elephantine majority she demanded. Aided by increased broadcast coverage, Labour began a gradual ascent in the polls. With the leaking of its manifesto, it surged.

If the intention of the leak was to harm Corbyn, it achieved the reverse. The manifesto, which pledged to abolish university tuition fees, cap housing rents, increase the minimum wage to £10, and renationalise the railways, the energy system, the water system and the Royal Mail, was hugely popular with voters (whose appetite for such policies had been clear for years). By simultaneously promising to renew Trident and to recruit 10,000 more police officers, For the Many, Not the Few also neutralised the charge that Corbyn was soft on security.

By contrast, the Conservative manifesto (Forward, Together) appeared actively designed to repel voters. It pledged to scrap the planned cap on social care costs, to strip pensioners of Winter Fuel Payments, to end universal free primary school meals and to continue public spending cuts. Though May spoke grandly of reforming British capitalism, there was little in the document to justify this boast.

The Prime Minister alienated the young and liberal Remainers by unashamedly embracing “hard Brexit”, supporting the restoration of fox hunting and rejecting a full ban on the ivory trade in Britain. When her social care policy (“the dementia tax”) was received “like a cup of sick” (in the words of one Conservative MP), May became the first Prime Minister to U-turn on a manifesto policy during a general election campaign. Her subsequent insistence that “nothing had changed” made her appear not only incompetent but delusional.

May had never led her party in a general election campaign - and it showed. As Corbyn grew in stature (with his name chanted at mass rallies), she shrank. Her refusal to participate in the TV debates made her appear afraid of the electorate (despite having forced them to the polls for the second time in two years). May’s endless recitation of Tory election slogans (“Strong and Stable”) led even Conservative MPs to label her “the Maybot”. Rather than benefiting the Tories (as Labour feared), the terrorist attacks that haunted the campaign exposed May’s police cuts to new scrutiny.

And so, a Prime Minister who called an election to increase her majority was left without one at all. Though the Conservative vote, swollen by Ukip defectors, rose to 42.4 per cent (its highest level since 1983), this was counteracted by Labour’s surge. Under Corbyn, who MPs had sought to depose just a year before, the party gained more votes than at any election since 1945 and achieved its highest share (40.0 per cent) since 2001.

Though Labour did not pledge to thwart Brexit, it benefited from waves of Remain voters. The party won Kensington, it won Canterbury, it surged in the south-west – it won majorities that would make Kim Jong-un blush. (But with 262 seats, Labour also remained 64 short of a majority, with just four more MPs than Gordon Brown in 2010.) Corbyn's internal opponents, who had hoped to depose him following defeat, were forced to accept him as their party's new master.

For May, like Stanley Baldwin, Clement Attlee and Edward Heath before her, the gambit of an early election backfired. Had the Conservatives not advanced in Scotland under Ruth Davidson, Corbyn would likely now be Prime Minister.

After retaining 318 MPs (12 fewer than David Cameron), May was forced to turn to the Democratic Unionist Party for a parliamentary majority. At a cost of £1bn (£100m per MP), the Northern Irish outfit obliged. But this cynical bung, and the DUP’s reactionary social stances (such as opposition to abortion and equal marriage), further retoxified the Conservative brand. With no majority of their own, the Tories were forced to abandon much of their programme (social care reform, new grammar schools, new austerity measures) and to promise the abolition of the public sector pay cap.

Though May’s position appeared perilously weak on election night, (George Osborne labelled her a “dead woman walking”), the absence of an agreed Tory alternative, and the unappetising task of Brexit, meant she survived electoral humiliation. But the Prime Minister's failure to meet the survivors of the horrific Grenfell Tower fire a week after the election, and her lackadaisical response to the tragedy, confirmed Conservative MPs' worst fears about her leadership.

On 19 June 2017 (11 days after the election), a weakened, rather than strengthened, Britain began to negotiate its departure from the EU. Though Brexit Secretary David Davis had promised the “row of the summer” over whether to agree divorce terms alongside a new trade deal, he capitulated on the first day of the talks.

The concession established an enduring pattern. After dismissing reports of a €40bn divorce bill as "nonsense, completely wrong" (in the words of Davis) and telling the EU to "go whistle" (Boris Johnson), Britain accepted precisely this sum. In defiance of May’s earlier speeches, the UK also agreed that the European Court of Justice would maintain oversight of European citizens' rights and that, in the absence of a solution to the Irish border problem, the UK would accept “full regulatory alignment” with the EU. Rather than advancing towards a new trade deal, the government was forced to plead for a two-year transitional period during which, to coin a phrase, nothing will change.

The UK went from being the fastest-growing major EU economy to the slowest (rendering it the new sick man of Europe) and rather than gaining £350m a week, was estimated to have foregone this amount. This was Brexit, but May wasn’t making a success of it.

There was little cheer for the Prime Minister away from Brussels. Boris Johnson shamelessly undermined her by tabling his own Brexit demands in a 4,000 word article for the Daily Telegraph. But May was too enfeebled to sack her errant Foreign Secretary.

The Conservative conference revealed a party that knew it was in trouble but didn’t know what to do about it. May’s own speech, intended to convey strength, instead dramatised her weakness. An address plagued by a prankster, a coughing fit and collapsing scenery served as an apt metaphor for her benighted premiership. May was fortunate that, of all Conservative MPs, Grant Shapps led the subsequent coup attempt. But she was largely tolerated rather than supported by her party.

The Tories’ name was further darkened by the Westminster sex scandal, which forced the resignation of Defence Secretary Michael Fallon (a decidedly unsafe pair of hands) and the suspension of backbencher Charlie Elphicke. Less than a week after Fallon’s departure, International Development Secretary Priti Patel was sacked by May for her diplomatic freelancing in Israel. On 20 December, the Prime Minister lost her closest cabinet ally of all, First Secretary of State Damian Green, after he repeatedly lied over the possession of pornography on his computer.

May’s allies celebrated relative successes: the non-implosion of the autumn Budget, permission to begin the second phase of the Brexit negotiations. But in the Commons, the Prime Minister’s loss of control was exposed. Eleven Tory rebels helped secure a “meaningful vote” for MPs on the final Brexit deal and forced May to abandon her attempt to codify the planned Brexit date (29 March 2019) in law.

In the face of all this, an increasing number spoke admiringly of the Prime Minister’s “resilience”. Some even suggested she could retain office until 2021. But for a leader who once aspired to mastery of British politics, the bar had been dramatically lowered.