Hillary Clinton pledges to work with president-elect Donald Trump for the good of the United States in emotional speech.

Hillary Clinton, the defeated candidate for US president, has pledged to work with president-elect Donald Trump to unite a divided nation in an emotional concession speech.

With a row of American flags in the background, the Democratic nominee told supporters that her loss was painful “and it will be for a long time,” and that she had offered to work with Trump as he prepares to begin his four-year term on January 20.

“Last night I congratulated Donald Trump and offered to work with him on behalf of our country,” Clinton said in New York before noon on Wednesday, joined by her husband, former President Bill Clinton and daughter Chelsea.

“I hope he will be a successful president for all Americans.”

After the Republican Trump’s stunning upset of the heavily favoured Democrat Clinton, Democratic President Barack Obama and leading figures in the Republican Party who had struggled to make peace with Trump all vowed to move past the ugliness of an angry and sometimes personal campaign to seek common ground.

Clinton said that the United States was “more deeply divided than we thought,” telling her supporters that they must accept the outcome of the election.

“I hope he will be a successful president for all Americans. This is not the outcome we wanted or we worked so hard for, but I believe in Americans,” she said. “We owe him an open mind and a chance to lead.”

Clinton said that the US had not “shattered that highest and hardest ceiling,” referring to the fact that, if elected, she would have become the first female president in the nation’s history.

“Someday, somebody will,” she said.

"To all the little girls watching…never doubt that you are valuable and powerful & deserving of every chance & opportunity in the world." — Hillary Clinton (@HillaryClinton) November 9, 2016

Al Jazeera’s Kimberly Halkett, reporting from New York, said many Clinton supporters would find it difficult to accept the result.

“We saw a lot of people angry and shouting saying they do not accept the results. People are really frustrated,” she said

“What is really important here is that what this campaign has done is that it underscored the diversity of America and the reflection of America – America that is more diverse than many have felt they have been able to acknowledge in the past.”

Click here to see more of Al Jazeera’s extensive US Election 2016 coverage

Thousands of people marched against Trump in New York, Chicago, Portland and other cities on Wednesday night.

Clinton’s running mate, Tim Kaine, said she had made history by paving the way for women to run for president.

Speaking before Clinton to a room of supporters and aides, Kaine prompted a standing ovation when he noted Clinton secured more of that popular vote than Trump.

His voice shaking, he said that Clinton “knows the system we have. She’s deeply in love with it and she accepts it.”

Protesters reach Trump Tower as they march in Manhattan, New York [Eduardo Munoz/Reuters]

A wealthy property developer and former reality TV host, Trump rode a wave of anger towards Washington insiders to win Tuesday’s election against Clinton, whose CV included stints as a first lady, US senator and secretary of state.

Trump’s victory marked a crushing end to Clinton’s second quest to become the first woman president. She also failed in a White House bid in 2008.

Obama, who campaigned hard against Trump, invited him to the White House for a meeting on Thursday after a brutal night for his party, which also fell short of recapturing majorities in both chambers of Congress.

READ MORE: Donald Trump – The Islamophobia president

“We are now all rooting for his success in uniting and leading the country,” Obama said at the White House , adding he and his staff would work with Trump to ensure a successful transition.

“We are not Democrats first, we are not Republicans first, we are Americans first,” he said.

Trump and his senior aides were meeting at Trump Tower in New York on Wednesday to begin the transition. The Republican majorities in both chambers of the US Congress will likely help Trump implement his legislative agenda.

Inside Story: Will America be great again?

In a victory speech early on Wednesday , he promised to embark on a project to rebuild American infrastructure and to double US economic growth.

Al Jazeera’s James Bays, reporting from UN headquarters in New York, said diplomats and ambassadors had privately expressed shock at Trump’s victory and uncertainty over what his policies would be.

“We don’t really know what the foreign policy now is of the United States – the most powerful country in the world,” he said.

“If you believe what Donald Trump said on the campaign trail, then he’s going to overthrow many things that were always the case for the United States since the second world war.”

Joined by his family at his victory speech, Trump spoke to cheering supporters in a New York hotel ballroom, saying it was time to heal divisions and find common ground after a campaign that exposed deep differences among Americans.

“It is time for us to come together as one united people,” he said. “I will be president for all Americans.”