Around the United States and throughout the world, people are waking up this morning and asking, 'What just happened?'

Donald Trump, the Republican nominee for the American presidency, was elected to lead the free world, against the expectations of most polls, pundits and political observers. He did it by getting his core supporters — white Americans — out to vote for him in bigger numbers than expected, delaying for at least one more electoral cycle the demographic challenges facing the Republican Party.

As of midday on Wednesday, it appeared that Hillary Clinton would emerge with the highest share of the popular vote. But winning the support of most Americans was a secondary concern to Trump. He needed to win the support of the most Americans in the right states, and he did just that.

The error in the polls was one-sided. Clinton met her polling numbers, taking as much of the vote as the polls suggested she would. Trump, on the other hand, beat his polls by about four points. That disparity is very similar to the one that occurred in 2012, when Barack Obama turned a near-tie into a four-point victory over Mitt Romney.

USA-ELECTION/TRUMP

Supporters celebrate as returns come in for Trump during an election night rally in Manhattan. (Mike Segar/Reuters)

The difference was just enough to put Trump over the top. Projections suggested a four-point swing would be needed to give Trump the victory.

Where did it come from? Support for third party candidates was well below their polling. Instead of nine per cent, the combined support for Gary Johnson, Jill Stein, Evan McMullin and others was only around five per cent.

Stein, whose Green supporters preferred Clinton over Trump by a wide margin, did about as well as expected. Johnson, however, lost about half of the support he had in the polls. It's possible that Republican-leaning Johnson supporters went for Trump in the end, while his Democrat-leaning voters stuck with him.

Or it could simply be a matter of turnout — Johnson's voters stayed home while Trump's came out in big numbers. Exit polls indicated that the electorate was angry, and the crux of Trump's campaign was to activate white voters who had previously checked out of the political system. He may have been successful.

The last polls of the campaign gave Trump an edge of about 15 points over Clinton among white Americans. The Democratic nominee compensated for this with about an 80-point lead among African-Americans and a roughly 40-point edge among Hispanics.

Exit polls suggest Clinton met her targets among minority voters. But she lost white voters by about 21 points — white men by 32 points. And though she seems to have won the support of college graduates overall, she still lost the vote among white college graduates. This has been a traditionally Republican-voting cohort that appeared to be swinging over to the Democrats in 2016. Apparently, that didn't happen.

Trump's Midwest surprise

A number of states that were expected to go to Clinton instead went to Trump, giving him the victory. He carried most of the swing states that were pegged to be the closest: Ohio, Florida and North Carolina, as well as Michigan and Pennsylvania.

This was seen as Trump's most likely path to the presidency. He beat his polls by two to four points in these states, while Clinton performed a point below hers.

Wisconsin was more of a surprise. The polls suggested Trump trailed there by more than five points. Clinton performed two points below her polls — her worst performance in the swing states she lost to Trump — while Trump beat his by six points.

USA-ELECTION/CLINTON

Clinton speaks at a campaign event in Milwaukee, Wisconsin. She lost the state in Tuesday's election, despite pre-election polls that showed her comfortably ahead. (Jim Young/Reuters)

Talk of the Democrats winning the House of Representatives ended quickly when Clinton's poll numbers started to falter over the final two weeks of the campaign. Republicans also defended their majority in the Senate.

Senate candidates beat expectations in the same places as Trump: Ron Johnson in Wisconsin, Pat Toomey in Pennsylvania and Kelly Ayotte in New Hampshire. 

In the House, the Democrats didn't come anywhere close to the gains they were expected to make. The result was instead more like a midterm when the electorate is whiter, older — and more Republican.

Where did the polls go wrong?

It's too early to say exactly why the polls were wrong, but it's a question that many will be asking in the coming days. 

A failure to forecast the demographic makeup of the electorate could be a contributing factor. Trump supporters who didn't turn up in the polling data — perhaps because many of them were considered unlikely voters based on past voting behaviour — may have also been behind his unexpected victory.

Undoubtedly, pollsters are already poring over their data to see what went wrong. And just as certainly, it will be some time before they're able to rebuild trust with Americans. But many across the country and the globe expect that could be the least of America's problems in the coming years.