London (CNN)It was meant to be the most predictable of election campaigns. A British Prime Minister with a comfortable lead in the polls calling an early election to strengthen her mandate to negotiate Brexit, up against a supposedly weak opposition leader from the unfashionable far left of his party.
Jeremy Corbyn: An anti-establishment underdog who's got the 'X Factor'
But with a week to go before the UK election, Theresa May's position is looking less than secure. Under her opponent Jeremy Corbyn, Labour is closing the gap in the opinion polls behind May's Conservative Party. His manifesto -- a raft of leftwing policies with renationalization of industry at their core -- has been well received by voters. Stories about Corbyn's past support for the Irish Republican Army and Hamas are failing to inflict serious damage. And in the wake of last week's suicide bombing in Manchester, the Labour leader's perceived weakness on security and counter-terrorism don't seem to have damaged him in the court of public opinion.
At the start of the campaign in April, the Prime Minister set down a narrative that the June 8 election was a choice between her "strong and stable" leadership that would deliver a successful Brexit, and Corbyn's far-left brand of Labour. It is still highly likely that May will win next Thursday. But as the campaign enters the final stages, it is remarkable how Corbyn has managed to change the narrative and turn the election into a competitive fight.
This shift has been achieved, say commentators, in part because Corbyn does not behave like an ordinary politician. While other party leaders adapt their policies to the changing times, his views -- including opposition to Britain's independent nuclear deterrent, and in favor of higher taxes on the rich to pay for healthcare and schools -- have not changed in more than 30 years.
Corbyn was raised in rural Shropshire in central England and was educated at a local grammar school before studying at a North London college, from where he left after one year, failing to finish a degree. After working for a number of trade unions he got his first break in politics at the age of 25 when he was elected to a council seat in Haringey, a borough in north London.
Nine years later he became Labour MP for the London seat of Islington North, at the same time Tony Blair entered Parliament. Their career paths could not have been more different: while Blair rose through the Labour Party to become its leader in 1994 and prime minister in 1997, Corbyn remained a backbench MP, rebelling against Blair in hundreds of votes in the House of Commons and most prominently as a vocal critic of the Iraq war.
It was after Labour's second electoral defeat in a row, in 2015, that Corbyn's name was put forward for the leadership contest as a "token" leftwinger, but was at first not taken seriously. He went on to win with nearly 60% of the vote.
In the same way Bernie Sanders experienced an insurgent tide of popularity from younger voters, 68-year-old Corbyn is most popular among 18-34 year-olds.
The success of Corbyn's anti-establishment pitch -- he saw off a challenge from the party's centrists in 2016 -- may also invite comparisons with the US president. Like Donald Trump, the Labour leader is prone to outbursts of tetchy, erratic and stubborn behavior.
By coincidence, Trump and Corbyn have each been married three times. Yet the similarities perhaps end there: Corbyn has the unassuming manner and bearing of a high school science teacher and likes to spend his weekends on his community garden plot, not playing a round of golf in a lavish hotel resort.
"There is a certain freshness about the Corbyn campaign which is attractive to people who are fed up with the staleness and tiredness of political discourse," says Tom Baldwin, who was director of communications for the previous Labour leader Ed Miliband at the 2015 election. "Corbyn himself doesn't look scared in interviews. He doesn't look scared of being found out."
"He has a really thick skin and he is very comfortable in it. As such there is an 'x-factor' to him which it would be churlish not to acknowledge."
On Monday evening, during a Sky News/Channel 4 program in which Corbyn and May were grilled by a studio audience and rottweiler interviewer Jeremy Paxman (separately, because the PM has refused to take part in a TV leaders debate), the Labour leader laughed off critical questioning and held his own. The Prime Minister, by comparison, appeared rattled by tough questions.
Yet Corbyn's thick skin showed signs of vulnerability on Tuesday morning when, in an interview for BBC Radio 4's Woman's Hour, he sounded flustered as he failed to answer a crucial question of how much Labour's plan to offer free childcare from the age of two would cost.
This incident highlighted two major weaknesses of the Labour leader: that his agenda will cost taxpayers a lot of money, and that his circle of advisers lack the experience and professionalism to have ensured Corbyn had the right figures in front of him.
This shaky grasp of figures can cut through to the opinion polls. So far, the Conservatives' lead has steadily narrowed since May called the election. Six polls taken since the Manchester attack showed a gap of between five and 12 points, down from between 15 and 20 points two weeks ago.
In the past two weeks, newspapers have highlighted Corbyn's links to the IRA and Hamas, including his appearances at events commemorating both organizations. But voters appear to be unmoved.
Baldwin says Corbyn has benefited from an absence of the kind of intense scrutiny normally applied to potential prime ministers because, unlike Miliband in 2015, "at the start of this campaign everyone thought Corbyn had a cat in hell's chance of winning". Opponents had not really had a chance to hone their attacks on Corbyn until now, he added.
But according to Baldwin, the narrowing in the polls is more as a result of failings in the Conservative campaign, including pinning so much on May as a "strong and stable" leader, which backfired because she was forced to perform a u-turn over a major policy on funding for elderly care. There has also been little effect in the polls from her position as an authoritarian, security-minded prime minister in the wake of Manchester.
"The Tories have been running a terrible campaign - that is the single most important factor in this election so far," says Baldwin. "They dropped the ball and it is very difficult to turn their line around. They have tried to make this all about her and have managed to tarnish her brand in the course of three weeks."
Now it is Corbyn, in his refusal to budge from his old fashioned brand of leftwing politics -- and perhaps because expectations of him, as the underdog, were already low -- who now appears to represent stability.
While it remains unlikely he will be prime minister next week, the Labour leader has turned the most predictable election in recent British political history into an unexpectedly dramatic race to the finish.