When Bernie Sanders first floated the idea of a run for the White House, in 2013, he presented his candidacy as a means of promoting debate within the Democratic party, rather than a serious bid for office. “Anyone who really, really wants to be president is slightly crazy,” he said.

As an obscure senator from the sparsely-populated state of Vermont and the only avowed socialist in Congress, there was no danger he would be nominated, much less elected, particularly considering that he would be up against Hillary Clinton - not merely the party establishment’s choice, but a popular and hugely experienced politician on a historic quest to become the USA’s first female president.

So much for the conventional wisdom. In this time of insurgent candidates, in which Donald Trump dominates the Republican field and Jeremy Corbyn is the leader of the Labour party, Sanders may be about to spring the greatest shock of all.

In Iowa, which holds its caucus on February 1, he has drawn level with Clinton in the polls - a CNN survey released on Friday showed him with a small lead for the first time. In New Hampshire, which votes a week later, he is ahead by double digits. It is distinctly possible that he will win both states. If he does, Hillary will have to take inspiration from her husband, Bill, the only candidate ever, from either party, to win the nomination without taking Iowa or New Hampshire.

Hillary, it is fair to say, really, really wants to be president. Why else would she submit herself to the scrutiny and the smears, the pre-dawn wake-up calls, the endless gripping and grinning that retail politics requires in these two states proud of their outsized impact on the American electoral process?

Eight years ago, her battle with Barack Obama dragged on all through spring and left a legacy of bitterness that took years to truly heal. At the Democratic National Convention in August 2008, Clinton’s supporters marched through Denver to claim that she had been robbed of her due.

Since then, she has rehabilitated her image, serving as Secretary of State for four years and demonstrating that she could be a team player in President Obama’s White House. Although she only formally declared her candidacy last April, she has been running a shadow campaign ever since she stepped down from the state department in 2013.

In polls last summer, Clinton was so far ahead of her rivals that a coronation seemed the most likely outcome. Vice President Joe Biden, after months of tiresome will-he-won’t-he, was dissuaded from running by her seemingly unassailable position. At Congressional hearings into the 2012 attack on the US Consulate in Benghazi, Libya, Clinton outclassed her Republican assailants. Even her critics conceded that she looked presidential.

So how has it come to this? Sanders is, by American standards, radically left wing. His democratic socialist platform of high taxes and a comprehensive welfare state would have been mainstream thirty years ago in Europe. Here it’s virtually the Communist Manifesto.

To an extent, Clinton is a victim of disenchantment with the rotten political system. Sanders has tapped into a deep vein of antipathy, just as Trump and Corbyn have. In image conscious American politics, he is seventy-four years old, with a stoop, thick glasses and thinning hair. He speaks in a rasping, untutored Brooklyn accent. This is not a pose - he’s been advocating the same policies and wearing the same ill-fitting jackets since he was Mayor of Burlington in the 1980s. Perceived authenticity is his greatest political asset.

Sanders does not accept financial support from banks or corporations. In the dark money era, when there is no effective limit on campaign contributions, this is like sending the cavalry in to face machine guns, but it’s also fundamental to his appeal. He has amassed more small campaign contributions - 2.3 million at the last count - than any previous candidate, including Obama in 2008. In the last quarter of 2015 he raised $33 million.

In the last week, Clinton has belatedly woken up to the threat that Sanders presents, with a series of attacks on the issues of gun control, universal healthcare and financial regulation. “I think a candidate who was originally thought to be the anointed candidate, to be the inevitable candidate, is now locked in a very difficult race,” Sanders said. “Obviously, what people in that scenario do is start attacking.”

Guns are a marginal issue for Sanders, but they’re also one of the few policy areas in which Clinton can get at him from the left. Hunting is popular in Vermont, and Sanders has a mixed record when it comes to firearms. Clinton has described him, rather disingenuously, as “a pretty reliable vote for the gun lobby.”

His advocacy of a single-payer healthcare system, similar to our National Health Service, is a trickier for her to unpick. During her husband’s administration she tried and failed to introduce universal healthcare to the United States. Her line now is: “We have the Affordable Care Act. Let’s make it work.”

Rather than suggest that Sanders’ proposal is unfeasible and politically risky, Clinton has taken a page from the Republican playbook and accused him of threatening to “dismantle” the hugely popular Medicare programme for senior citizens - it would be more accurate to say that he proposes to extend it to everybody.

Sanders would raise income taxes on the wealthiest to fund an ambitious social welfare programme including free university tuition and universal healthcare. Clinton recently announced that she would introduce a 4% surcharge on earnings of more than $5 million per year - a shift the Sanders campaign dismissed as “too little, too late.”

Clinton’s unrivalled fundraising operation is a liability when faced with an insurgent left wing opponent. At the most recent Democratic debate, Sanders noted that Clinton could hardly be expected to reform the financial system or break up the banks when she has taken so much of their money, including $600,000 in personal speaking fees from Goldman Sachs in a single year.

The primary schedule favours outsider candidates. The most liberal and most conservative voters are the most motivated to take part, to begin with. The media has a clear interest in promoting a close race. Iowa and New Hampshire are quirky, predominantly white states. The question is whether Sanders can kick on or whether he will fade away, like Gary Hart in 1984, Bill Bradley in 2000 and Howard Dean in 2004.

Comparisons with Barack Obama’s 2008 campaign are unavoidable. In the autumn of 2007, Clinton had an aura of inevitability and a huge lead in the polls. It was only when Obama won in Iowa that African-Americans, in particular, began to switch their allegiance, making him competitive in southern states.

The memo that Obama’s campaign circulated, outlining how to go after Clinton, is in the public domain now. Suggesting that she is a calculating, power-at-all-costs operator and not to be trusted was central to their strategy. The campaign slogan they chose - “change you can believe in” - was a subtle attack in the guise of an inspirational war cry.

Clinton is still vulnerable to this charge. She was for the Trans-Pacific Partnership before she was against it, for instance, a fact that Sanders is sure to remind her supporters in the trade union movement at every opportunity.

The next states to vote after New Hampshire are Nevada and South Carolina. Then on ‘Super Tuesday,’ March 1, eleven more states go to the polls, including Texas, Tennessee, Arkansas, Georgia and Virginia.

Clinton currently has large leads across the map. In national polls, she is still way ahead of Sanders. A New York Times/CBS survey found that the gap had narrowed to seven points, only for a Wall Street Journal/NBC poll to suggest that it is more like twenty-five. It is too early, and the situation is too volatile, for such polls to be much use.

More interesting data can be found by burrowing a little deeper. Sanders has clearly energised younger Democrats, as Obama did eight years ago. Among voters under forty-five years old, he has twice as much support as Clinton.

Black and Latino voters favour Clinton by large margins. In a recent NBC News poll of registered Democrats, just 12% of the African-Americans and 27% of the Hispanics surveyed said they would back Sanders. He cannot win the nomination with numbers like those.

Following some high-profile run-ins with Black Lives Matter protesters at his rallies, Sanders has been making a concerted effort to woo African-American voters. He has hired a young black press secretary, Symone Sanders (no relation). Popular rapper Killer Mike has endorsed him.

On Martin Luther King day, Sanders addressed a crowd of around seven thousand people in Birmingham, Alabama. “What good is having the right to sit at a lunch counter if you can’t afford to buy a hamburger?” he asked rhetorically, quoting the civil rights icon. King’s message, that racial equality is worthless without social and economic justice, could be a potent line for Sanders. Having an African-American in the White House has done nothing to reduce the huge disparities of wealth and opportunity between black and white.

Online, Sanders supporters circulated a picture showing their man at the March on Washington, alongside a shot of Clinton as a young Republican, working for the Barry Goldwater campaign. The caption: “What did you do in the 1960s?”

Even if Sanders can win over substantial numbers of black voters, Clinton will still boast formidable advantages. She has secured the vast majority of so-called ‘super-delegates’ - unelected party representatives that have a say in choosing the nominee. Forecasting website Five Thirty-Eight is tracking the endorsements each candidate receives, awarding ten points per governor, five points a senator and one for each member of the House of Representatives. In the latest tally, Clinton has 458 points. Sanders has two.

Clinton’s most recent campaign advert features a montage of Republican candidates making bellicose statements - Trump: “I would bomb the shit out them,” Jeb Bush: “Repeal Obamacare,” Ted Cruz: “Defund Planned Parenthood,” and so on. “Who’s the one candidate who can stop them?” asks the payoff. “Hillary Clinton, tested and tough.”

Her pitch is that in a corrosively partisan era, with Republican control of the House of Representatives guaranteed by gerrymandered congressional districts, progressives need a warrior in the White House, hard as steel, forged in the heat of battle. Even if he were to be elected, she argues, Sanders would stand no chance of enacting his agenda.

In Washington DC, Clinton has a reputation for being frighteningly capable and well-briefed, for working harder than anyone else, and for hard-won expertise in the mechanics of legislative compromise. In this era of unprecedented disenchantment - disgust, even - with the political system, it may count against her.