Donald John Trump was elected the 45th president of the United States this week in a stunning culmination of an explosive polarizing campaign that promised building a wall on the border between Mexico and the United States.

The surprise outcome, defying polls that showed Hillary Clinton leading Trump left many in the country and around the world stunned.

The triumph for Mr. Trump, 70, a real estate developer-turned-reality television star with no government experience, was a powerful rejection of the political establishment that had assembled against him, from the world of business to government.

The results amounted to a repudiation, not only of Mrs. Clinton, but of President Obama, whose legacy is suddenly imperiled.

“The forgotten men and women of our country will be forgotten no longer,” Mr. Trump told supporters around 3 a.m. on Wednesday at a rally in New York City, just after Mrs. Clinton called to concede.

In a departure from a blistering campaign in which he repeatedly stoked division, Mr. Trump sought to do something he had conspicuously avoided as a candidate: Appeal for unity.

“Now it’s time for America to bind the wounds of division,” he said. “It is time for us to come together as one united people. It’s time.”

Bolstered by Mr. Trump’s strong showing, Republicans retained control of the Senate. In Wisconsin Ron Johnson retained his Senate seat by defeating Democrat Fiengold.