The market-shaking, expectations-defying prospect of a Donald Trump presidency appeared close to reality Tuesday, hinging perhaps on the outcome of states rarely deemed major national battlefields: Michigan and Wisconsin.

If Trump wins either, it's virtually over. Early returns not only showed him with slight leads in both, but also gaining ground in what would be a clear knockout state, Pennsylvania, where initial returns showed him losing.

He was written off again and again, repeatedly shocking the political establishment since last year — first by running, then by becoming a contender, winning the nomination and now knocking on the door of the White House.

''It's happening,'' his spokesman Jason Miller tweeted earlier.

Trump vastly outperformed electoral prognostications and market forecasts that viewed a historic Hillary Clinton victory as a fait accompli, leading in Florida, taking Ohio, and mounting surprisingly strong challenges in northern industrial states that hadn't gone Republican in decades.

Suddenly, Clinton was the underdog.

The prospect of a Trump presidency jolted the markets: futures markets plunged hundreds of points, as did the Mexican peso.

His threat to scrap trade deals and slap tariffs on foreign-made goods as punishment for job outsourcing might have dismayed many Canadians, economists, businesses and brokers. Yet it was central to his message to white working-class voters in the old industrial belt.

Democrats made another bet — that his comments about Mexicans, Muslims and women that made him a hero to white-supremacist groups would prove so disgusting to other voters that Clinton would be carried to the presidency on the backs of minorities, the college-educated, and females, the coalition that elected Barack Obama.

He was considered so unpalatable a choice by so many that senior members of his party refused to endorse him or appear at election rallies with him. He was shunned by every living Republican nominee except Bob Dole.

The Bushes made it known they didn't vote for him, along with Mitt Romney and John McCain. A former speechwriter for George W. Bush offered an example of the fatalistic attitude permeating political circles in Washington.

''On the bright side, 227 years is a really good run for a republic,'' tweeted Canadian David Frum, referring to the number of years since George Washington became the first American president.

At Trump headquarters in Manhattan, people chanted, ''U-S-A!'' and, ''Lock her up!'' in reference to Hillary Clinton. People were reportedly in tears, some even leaving early at the Democratic gathering across town.

Democrats began the evening expecting to celebrate a different kind of history.

Clinton had an evening rally scheduled under a see-through roof, a symbolic nod to the prospect of the first female president smashing the ultimate glass ceiling and occupying perhaps the most powerful office in the world.

Her campaign was repeatedly sidetracked: by hacks of her aides' emails, conflict-of-interest allegations into her family's charitable foundation, an investigation and leaks from the FBI and voter confusion about her platform.

The Democrats' campaign even focused on Trump.

Clinton's platform, titled "Stronger Together," was a nod to her opponent's racially tinged rhetoric. The message obscured the actual purpose of her platform — economic inequality. Some elements, like a parental-leave program, are shared by her rival — who is the least conservative Republican nominee in memory.

Trump's inimitable style of American populism veers from right to left; from military hawkishness to doveish language. He could have the opportunity to pass an unusually high number of bills, depending on which party agrees with his policy of the moment.

His North American neighbours would be watching nervously for moves on trade. He's demanded a renegotiation of NAFTA, without offering details, and promises to rip it up if unsuccessful.

One Canadian official expressed doubt in a recent conversation that it would get that far. Even if a president did order NAFTA scrapped, the impact of the move would be softened by several firewalls — the need for Congress to reinstate old tariffs, and potentially by the continued existence of the old 1987 Canada-U.S. agreement.

"I don't really think we're in danger there," said the Canadian official. "There would be a revolt by the private sector... His own party would revolt.''

If it happens, a Trump victory would also deprive the current president of a historic achievement.

A Democratic win would have placed Barack Obama in the company of Franklin Roosevelt and Ronald Reagan as the only postwar presidents to have a successor extend their party's time in the White House beyond two terms.

It would now require a political miracle.

Republicans roared to big victories down-ballot that allowed them to retain some control of Congress: they held the House of Representatives as expected, and saw their chances of retaining the Senate massively boosted by wins in Indiana and Marco Rubio's re-election in Florida.

Keep reading