The American electorate, it appears, was angrier than the most recent polls had suggested.

Republican Donald J. Trump, a developer and former reality TV star, garnered enough electoral votes early Wednesday to become the nation's 45th president after a campaign in which he promised to rout the Washington elites and smash a "rigged" political system.

It was a stunning upset likened to the United Kingdom's "Brexit" referendum earlier this year to quit the European Union, amid a popular backlash against globalization and the political and business leaders who have pushed it. Trump zeroed in on that anxiety with his advocacy of restrictions on immigration and protectionist trade policies.

Democrat Hillary Clinton was denied in her bid to become the first female U.S. president, nearly a century after women won the right to vote.

The campaign exposed bitter divisions in the electorate, and the result was sure to throw the country into chaos, or at least uncertainty. Already, stock market futures plunged ahead of Wednesday's trading, reflecting investor concern over what a Trump presidency might mean for the economy and trade.

The race flip-flopped all evening, almost county by county, as votes trickled in from various states.

Trump won Pennsylvania, which the Democratic nominee has carried in every presidential election since Bill Clinton's victory in 1992. He did better than expected in battleground states that late polls suggested he had been poised to lose. He captured Ohio, with 18 electoral votes; Florida, the largest battleground prize with 29 electoral votes; and North Carolina, with 15 electoral votes.

"Some states are too close to call," Clinton campaign chairman John Podesta said a little after 2 a.m. as he informed her supporters that the candidate would have nothing to say "until all the votes are counted. It is not done yet."

Judy Norris, at an election watch party in Delaware County, had given up hope on Trump at 9 p.m. But by 10:40, gathered with others around an iPad showing returns on CNN, the 69-year-old retired teacher was borderline ecstatic.

"I am feeling that my prayers are almost answered for Donald J. Trump to make America great again," Norris said, moments before CNN called Ohio for Trump.

Exit polls showed women nationwide supported Clinton by a double-digit margin, while men were significantly more likely to back Trump. More than half of white voters backed the Republican, while nearly 9 in 10 blacks and two-thirds of Hispanics voted for the Democrat.

Trump, who had never held political office, campaigned on a simple platform: to "make America great again." He harnessed fears of illegal immigration, repeatedly promising to build a border wall that Mexico would pay for in a pledge that became an inevitable chant at his raucous rallies.

If elected, he said he would repeal Obamacare, appoint Supreme Court justices who would overturn Roe v. Wade, and possibly end the NATO alliance.

His rise surprised pundits and some Republicans, who thought voters were flirting with the political novelty but would soon sober up. Instead, Trump emerged victorious from a chaotic 17-candidate GOP primary field - upending the Republican Party in the process.

He provoked controversy after controversy: from his early assertion that Mexico was sending rapists to the United States, to his reluctance to concede that President Obama was born in the country, to his criticism of a Pakistani American couple whose Army captain son was killed in Iraq.

For some Republicans, the last straw was the surfacing of a 2005 tape in which Trump boasted about grabbing women by the genitals.

But the businessman prevailed, backed by a base that responded to his immigration focus and saw him as unfiltered and independent, a contrast to the Washington establishment they were fed up with.

Trump's campaign flouted conventional wisdom, buying very little television advertising and foregoing a traditional get-out-the-vote effort. Unlike decades of presidential candidates, he refused to release his tax returns.

His support was strongest among white, non-college-educated voters. In a political climate rife with suspicion of Washington and the donor class, he was embraced as an outsider who could shake up the establishment.

He expressed admiration for Russian leader Vladimir Putin, and, when the polls tilted against him, dangled the possibility he wouldn't accept the results of the election.

Clinton, the former secretary of state, U.S. senator and first lady, ran as the tested, reliable choice in a high-stakes race, casting Trump as a volatile, divisive figure.

Many voters struggled to accept either choice.

James and Anna Waldron, 84 and 86 years old, didn't like either candidate, but the registered Republicans voted straight party.

"This is the crookedest election I've ever seen. And I've seen quite a few," said James Waldron, adding that his wife made him come to Bensalem High School to vote.

John Bedeian, a 64-year-old registered Republican and investment adviser, voted for Trump, even though he "can't stand" him.

"I held my nose and voted for a man who met my number one need, which is change," said Bedeian, of Easttown Township. "I have to believe Donald Trump will come closer of the two to have the people's back."

"The Clintons are ethically challenged. They've proven this," he said.

While Clinton often made the case for her readiness, she battled doubts in her trustworthiness.

In the last week and a half of the campaign, critics seized on the reemergence of the FBI investigation into her private email server, spurred by FBI Director James Comey's announcement of new emails. Some top Republican lawmakers openly discussed the prospect of impeachment, if she won.

Comey told Congress on Sunday that he had not changed his conclusion that Clinton should not face charges over her handling of classified information.

Women who turned out in pantsuits and suffragette white with the hope of electing the United States' first woman president will have to wait for another election cycle.

"I pray to God she gets it," said Joanne Johnson, a retired teacher from Haddonfield who voted for Clinton Tuesday.

856-779-3232

@maddiehanna

Staff writers Michaelle Bond, Maria Panaritis, and Melanie Burney contributed to this report.