Donald Trump, sweeping to victory as the 45th president of the United States in a bitterly fought campaign that defied the polls, pledged Wednesday to "be a president for all Americans."

The 70-year-old real estate mogul's stunning upset came as, one by one, he stormed through battleground states — Florida, Ohio, North Carolina and then Wisconsin — to tear down Democratic challenger Hillary Clinton's seemingly formidable "blue wall."

While decisive, Trump's victory was also close. At mid-morning, Trump — needing 270 electoral votes to claim victory —had 276 to to Clinton's 218 with 44 votes still undecided.

The popular vote count proved even closer, with Clinton leading at mid-morning by a razor-thin margin of 47.7% to Trump's 47.5 out of more than 118 million votes cast.

"Such a beautiful and important evening!" Trump tweeted at around 6.35 a.m. ET Wednesday. "The forgotten man and woman will never be forgotten again. We will all come together as never before."

The often bombastic Trump struck a conciliatory tone as he addressed an enthusiastic crowd of supporters in New York to claim victory.

"I pledge to be president for all Americans," the billionaire real-estate mogul and reality TV star told an enthusiastic crowd of supporters in New York after his victory was confirmed. "We are going to rebuild our inner cities... We will rebuild our infrastructure, which will become second to none." He also pledged to create jobs and take care of veterans.

Trump said he congratulated Clinton for a "very, very hard-fought campaign."

"Hillary has worked very long and very hard over a long period of time, and we owe her a major debt of gratitude for her service to our country," he said. "I mean that very sincerely. Now it is time for America to bind the wounds of division, have to get together. To all Republicans and Democrats and independents across this nation, I say it is time for us to come together as one united people."

On Wednesday morning, President Obama called the president-elect "to congratulate him on his victory" and invite him to the White House on Thursday to discuss the transition, the White House said in a statement.

“Ensuring a smooth transition of power is one of the top priorities the President identified at the beginning of the year and a meeting with the President-elect is the next step,” the statement said.

As the victory was sealed after midnight Tuesday, Vice President-elect Mike Pence spoke first to supporters in New York, thanking them for their hard work and enthusiasm.

"This is a historic night," Pence said. "The American people have spoken and the American people have elected their new champion."

Trump claimed victories in Pennsylvania, Wisconsin, Iowa, Utah, Idaho, North Carolina, Florida, Georgia, Ohio, Missouri, Montana, Louisiana, Arkansas, Kansas, North Dakota, South Dakota, Texas, Wyoming, Alabama, West Virginia, Kentucky, Oklahoma, South Carolina, Tennessee and Indiana.

Pollsters and pundits have given Trump little chance of claiming the job ever since announcing his candidacy in a raucous speech in June 2015. But he quickly took the lead in a crowded Republican field, sweeping to the nomination despite drawing tepid support from party leaders.

Protesters take to the streets following Trump's stunner

Even as Tuesday began, he was given little chance of victory. But starting with Florida, almost every competitive state seemed to go his way.

"Things that were true: undercover Trump vote; @mike_pence for VP; Hillary's floor & ceiling r same; rally crowds matter; we expanded the map," Trump campaign manager Kellyanne Conway tweeted at 1:30 a.m. ET, an hour before victory was sealed.

Trump’s strong showing brought angst to world financial markets, with the Dow Jones industrial average falling as much as 500 points in after-hours trading. European stock markets and U.S. stock futures trimmed earlier losses later Wednesday after Trump's relatively soft victory speech helped reassure investors. Brad McMillan, chief investment officer at Commonwealth Financial Network, said a Trump win would spark uncertainty and likely result in a steep fall in stock prices Wednesday.

Clinton claimed California, Hawaii, Oregon, Washington, Nevada, Colorado, Virginia, Illinois, New York, Connecticut, Rhode Island, Maryland, Massachusetts, Delaware, New Jersey, Vermont and Washington, D.C.

Trump and Clinton mostly shunned public appearances as the day wore on, although Trump conducted radio interviews and their social media accounts were far from silent.

"Don't let up, keep getting out to vote - this election is FAR FROM OVER! We are doing well but there is much time left. GO FLORIDA!," Trump tweeted before the state was won.

How to make sense of what's happening as polls close on election night

When Utah, a red state, reported problems, Trump pounced, tweeting "Just out according to @CNN: "Utah officials report voting machine problems across entire country."

Not so, CNN's Brian Stelter tweeted: "No. Utah officials reported machine problems across one entire COUNTY, not the entire COUNTRY."

Russian president Vladimir Putin sent Trump a telegram of congratulations while Dutch far-right politician Geert Wilders tweeted his praise.

European Union leaders Donald Tusk and Jean-Claude Juncker issued a statement congratulating Trump and said "it is more important than ever to strengthen transatlantic relations."

British Prime Minister Theresa May congratulated Trump and said she looked forward to working with him.

"Britain and the United States have an enduring and special relationship based on the values of freedom, democracy and enterprise. We are, and will remain, strong and close partners on trade, security and defence," she said in a statement.

More than 1,000 people gathered outside the White House before the results were announced to protest against a Trump administration, Fox News reported.

Anti-Trump protesters took to the streets in Berkeley and Oakland in California, in Portland, Ore, and in Seattle after Trump's victory was declared, according to media reports.

In Portland, more than 100 protesters blocked traffic as they marched to Portland State University, KGW-TV reported.

Harun Khan, secretary general of the Muslim Council of Britain, an umbrella body that has more than 500 affiliated organizations including mosques and schools, congratulated Trump, who has called for Muslims to be barred from entering the United States, but said "there is a justifiable concern about his election."

"It is hugely worrying that a man who has openly called for discrimination against Muslims and other minorities has become the leader of a superpower nation," he said in a statement.

In Congress, Democratic hopes to gain five Senate seats needed to achieve a majority collapsed as the night wore on. Sen. Marco Rubio, R-Fla., had said while running for president that he would not seek re-election. He changed his mind and provided his party with a boost.

"Congratulations on the great victory, @marcorubio! Florida is critical to keeping the Senate," tweeted Jeb Bush, a former Florida governor who, like Rubio, was vanquished by Trump in the Republican presidential primaries.

In Indiana, former Democratic senator and governor Evan Bayh lost to relative unknown GOP Rep. Todd Young. Republicans also held key seats in North Carolina and Wisconsin and were leading key races in Missouri and New Hampshire. In Pennsylvania, GOP Sen. Pat Toomey fought back a stiff challenge from former state environmental secretary Katie McGinty.

Democrats did pick up a consolation prize, with Illinois with Rep. Tammy Duckworth ousting Republican Sen. Mark Kirk.

In the House of Representatives, Republicans were poised to maintain a solid majority.

More than 110 million votes had been counted in the presidential race by 2:30 a.m. ET, with millions more outstanding. Voters in several states had complained of long lines and computer malfunctions and other problems.

North Carolina kept some precincts open past the 7:30 p.m. ET closing time to allow voters slowed by glitches.

Is it Trump or Clinton?

In California, violence forced a lockdown of two polling places. Los Angeles County Registrar-Recorder/County Clerk Dean Logan tweeted that voters in Azusa should seek alternate polling sites after a shooting affected two voting locations, including an elementary school. A gunman shot several people, killing one, and scattered would-be voters, police said.

Across the nation, surveys of voters leaving their polling places revealed an electorate more diverse, more educated and more upset than four years ago.

The surveys also showed that black and Hispanic voters continued to grow as a percentage of the electorate, while the white vote slipped slightly. Still, white voters made up 70% of the electorate and supported Trump 55%-37%, the surveys showed.

The surveys, from National Election Pool Survey by Edison Research, showed nearly a quarter of Americans described themselves as “angry” about the way government is functioning. Those people were at the core of Trump’s support. In 2012, about a fifth of voters described their feelings toward the Obama administration as “anger.” The controversy over Trump's comments about women notwithstanding, the “gender gap” appears to be comparable to what voters reported in both 2012 and 2008 — female voters were more likely to support Clinton and male voters were more likely to support Trump. And while men favored Trump, his numbers appeared to be little changed from Mitt Romney's in 2012.

Contributing: Stephen Reilly, Adam Shell, Erin Kelly, Jane Onyanga-Omara

Corrections and clarifications: An earlier version of this story misstated the day in which Trump made his acceptance speech.