DONALD TRUMP’S road to the White House, which he completed with his stunning victory over Hillary Clinton on November 8th, began on an escalator at Trump Tower in Manhattan 17 months ago. Descending at a stately pace to the foyer, where a crowd of bemused journalists awaited him, the reality-television star was lampooned as a false prophet on a conveyor belt. What followed struck many pundits as even more ridiculous. “Our country is in serious trouble,” he said. “We used to have victories, but we don’t have them. When was the last time anybody saw us beating, let’s say, China in a trade deal? They kill us. I beat China all the time.”

It seemed like a bad joke. Mr Trump was a billionaire property developer who surveyed the world from the 26th floor of a Manhattan skyscraper he built: America hadn’t done him too badly. Moreover, his zero-sum view of diplomacy and protectionism were, at best, marginal positions in the party whose nomination he sought. Many also noted that Mr Trump, a political gadfly who is on his third party, had until recently espoused different views, including on immigration, which he announced as the cornerstone of his campaign.

After Mitt Romney lost the 2012 presidential election, Mr Trump seemed to berate “the Republicans”, as he still calls his party colleagues, for failing to back immigration reform. But in Trump Tower he raged against Mexican immigrants whom he called “rapists.” It was hard to recall a presidential contender making such bigoted remarks since the civil-rights era. Many commentators gawped, fascinated, then dismissed his chances.

But what the pundits decried—his contempt for conservative orthodoxy, his dystopian vision, bigotry, anti-intellectualism and egomania—now looks like a fully formed, stunningly successful campaign which, if it has not rewritten the rules of electioneering, got away with flouting most of them. Mr Trump raised less money than Mrs Clinton, built less campaign infrastructure, had few thought-out policies and was endorsed by almost no newspaper and none of his predecessors as Republican nominee, except Bob Dole. And instead of restraining his intemperance, as his advisers often told him to, he let it rip.

Unqualified success

He backed torture, a border ban on Muslims, murdering the families of suspected terrorists and using nuclear arms as a tactical weapon. He denigrated women, Muslims and blacks, performed a mocking impression of a disabled journalist, incited his crowds to beat up protesters, and was heard, on a videotape aired a month before the election, boasting of his ability to grab women by the genitals. There is an interesting dispute about what role the media, hungry for the conflict Mr Trump stirred, played in his rise. But Americans heard these things unfiltered—and even many of Mr Trump’s supporters disapproved of them. Exit polls suggest 61% of voters considered him unqualified to be president and only 34% said he had the right personality and temperament. Yet almost 60m Americans, including many of those doubters, voted to make him president. How did this happen?

Chance and the complacency of others played a part. For most of the Republican primaries, Mr Trump profited from a crowded field. While his 17 opponents, including solid conservatives such as Governor John Kasich and Senator Marco Rubio, fragmented the vote, he built a steady lead among disaffected voters, especially blue-collar workers who shared his pessimism and hostility to immigrants and free trade. It was not until the 36th state up for grabs, his own New York, that Mr Trump won a majority; and that the increasingly horrified Republican leadership gave much thought to stopping him. Having bagged the nomination nonetheless, he enjoyed other advantages. After eight tough years, of a Democratic government blighted by slow wage growth and, for most of that time, political deadlock imposed by a Republican Congress, voters wanted change. Only 31% say America is on the “right track”. The gravity-defying popularity of Barack Obama—whose 52% approval rating makes him more popular than Ronald Reagan at the end of his second term—had seemed to soften that anti-incumbency kick. Yet Hillary Clinton, despite some dazzling last-ditch campaigning by Mr Obama and his even more popular wife, Michelle, could not reap the benefit of it.

An establishment figure in a time of anti-establishment rage, the Democratic nominee was another gift to Mr Trump. Her strengths include deep understanding of the political system, acquired over three decades in or close to power, and a flair for policy; but most voters consider the system corrupt and, thundering for change, her vision of progress by inches inadequate. She was crippled by her weaknesses, including an inability to enthuse and a much-exaggerated reputation for deceitfulness, which an unending controversy over her e-mail arrangements as secretary of state exacerbated. Had Mrs Clinton roused Mr Obama’s coalition of non-whites, the young and well-educated she would have won. In Philadelphia, where she held a pre-election rally on November 7th, at which her husband Bill, Mr and Mrs Obama and Bruce Springsteen all performed, she won 28,000 fewer votes than Mr Obama in 2012. That was close to her margin of defeat in Pennsylvania, a state where she had led in 107 of the 125 most recent polls and which last went red in 1988. Following Mr Trump’s victories in Florida and North Carolina, this made his victory look probable.

Clinton’s curse

In almost every group, Mrs Clinton underperformed her predecessor. She won non-whites and young voters by 74 and 55 percentage points respectively, around ten points less than Mr Obama had. Her saviours were predicted to be the two groups most insulted by her rival, Hispanics and women. Yet she won only 65% of the first and 54% of the second, six points and a point less than Mr Obama managed. College-educated women, who backed her in recent polls by 2:1, ended up favouring her by just six percentage points.

Great expectations A more appealing Democrat could have beaten Mr Trump. But it is not clear who that might have been; Bernie Sanders, Mrs Clinton’s much-loved socialist rival in the primaries, and Joe Biden, the vice-president, are not as formidable as bruised Democrats now imagine them to be. After eight years in power, their party looks denuded of top-level talent. This was especially evident in the Senate races, for which it put up too many has-beens, like Governor Ted Strickland in Ohio and Governor Evan Bayh in Indiana, and greenhorns such as Katie McGinty in Pennsylvania, all of whom lost. The stronger Republican slate had consistently outpolled Mr Trump, but he probably ended up helping it, especially in Wisconsin, which he turned red for the first time since 1984, helping Senator Ron Johnson to a surprise victory. Despite having 24 senators up for re-election, the Republicans lost only two seats, leaving them with a thin majority. More predictably, they also maintained their previously thumping majority in the House of Representatives. The Democrats needed a net gain of 30 seats to overturn it, and picked up eight. Under Mr Trump, who has promised to kick off his presidency by appointing a conservative to the Supreme Court and dismantling much of Mr Obama’s legacy, America will have a unified government for the first time since the beginning of Obama’s first term. Despite his advantages, he was also responsible for that, for there was a method in his approach. Mr Trump’s erstwhile pragmatic remarks on immigration suggest he was at least familiar with the prevailing view that, to regain power in an increasingly diverse society his party needed to expand its appeal beyond whites. Yet his chauvinism and miserabilism pointed, from the start, to the opposite conclusion: that by stirring up a racially infused white nationalist sentiment, which a combination of economic and cultural grievances had spawned, he could turn a losing coalition into a winning one. Most likely, this was intuitive, a quality Mr Trump praises in his decision-making. Though born rich, he seemed genuinely attuned to those grievances. Asked, in an interview with The Economist during the primaries, how this was possible, he said: “You know my father was a builder in Brooklyn and Queens, predominately. And I worked with subcontractors…somehow even though I live on Fifth Avenue and all of these things, I very much relate to those people.”

Berned then burned

He was being too modest. Mr Trump won big among whites without a college degree. They made up a third of the electorate, and backed him over Mrs Clinton by 39 points. But at Mr Trump’s hate-charged rallies, at which his supporters yelled “Burn her at the stake” of Mrs Clinton and “Kill Obama”, middle-income white professionals were easy to find; 49% of college-educated whites voted for him, only slightly fewer than had backed Mitt Romney.

Though some votes are yet to be counted, overall Mr Trump has so far won 1m fewer than Mr Romney, and ended up trailing Mrs Clinton—who for her part won 6m fewer than Mr Obama—in the popular vote. He beat her, by 279 to 228 votes in the electoral college, because his strength with white, working-class voters was sufficient to flip Michigan, Pennsylvania and Wisconsin, all of which Mrs Clinton had been expected to win easily. It was close, with Mr Trump’s combined advantage in that trio a little over 100,000 votes. Perhaps the damage Mrs Clinton suffered from an ill-judged intervention from the FBI’s director, James Comey—eleven days before the poll he raised a fresh suspicion about her e-mails, which he then tried to allay a week later—accounted for some of those votes, which, combined with winning the popular vote, will feed Democrats’ sense of grievance.

Mr Trump’s victory has left a country shocked and ravaged by discord, especially along racial lines. This goes far beyond the usual partisanship. Half of America can scarcely believe the other half has chosen Mr Trump. At his celebrations in New York, the Republican victor struck a gracious note: “Now it’s time for America to bind the wounds of division.” In the background, one of his supporters meanwhile hollered: “Kill Obama”. His presidency will be defined by how he reconciles those competing instincts.

CORRECTION: This article has been updated to make it clearer that the vote totals mentioned above are incomplete.