(BBC) The US electoral college has certified Donald Trump as the 45th president, despite a last-ditch effort to deny him the White House.
Six weeks after winning the polls, the Republican cruised past the 270 votes needed to formalise his victory.
After the result, Mr Trump promised to “work hard to unite our country and be the president of all Americans”.
Electors had been flooded with emails and phone calls urging them not to support the billionaire.
But despite longshot liberal hopes of a revolt by Republican electors, only two – from Texas – ended up voting against him.
‘No treason, no Trump!’
Mr Trump secured 304 votes, compared with 227 for Hillary Clinton.
It was the Democratic candidate who ended up losing more electoral votes in Monday’s ballot at state capitols nationwide.
Five of her electors defected, with three voting for ex-Secretary of State Colin Powell, one for a Native-American tribal leader and another for Vermont Senator Bernie Sanders.
The electoral college result will be officially announced on 6 January in a special joint session of Congress.
“I thank the American people for their overwhelming vote to elect me as their next president of the United States,” Mr Trump said in a statement after the result came in.
“With this historic step we can look forward to the bright future ahead.”
One of the Democratic electors who did vote for Mrs Clinton was her husband, Bill Clinton, and he angrily lashed out at Mr Trump.
According to an upstate New York newspaper, the former president said of Mr Trump in a local book shop on Saturday: “He doesn’t know much. One thing he does know is how to get angry, white men to vote for him.”
Mr Clinton also told the weekly Bedford and Pound Ridge Record-Review that FBI Director “James Comey cost her (Mrs Clinton) the election” by reopening an inquiry into her emails.
He was also incredulous at Mr Trump’s cordial tone during a phone call the day after the election, saying the Republican had acted “like it was 15 years ago” when he was on good terms with the Clintons.
The voting process is usually a formality, but was overshadowed this year by claims that Russian hackers tried to sway the presidential election.
Millions of Americans signed an online petition stating that Mr Trump was unfit for the Oval Office, while anti-Trump protesters gathered at state capitols across the country.
In Pennsylvania, more than 200 demonstrators braved sub-zero temperatures, chanting: “No treason, no Trump!'”
In Maine, protesters beat drums and waved signs saying: “Don’t let Putin Pick Our President.”
In Madison, Wisconsin, demonstrators cried.
Numerically, Mr Trump’s opponents never stood much chance. To keep him out of the Oval Office, 38 Republican electors would have had to defect.
Even that would probably only have delayed the inevitable.
If no candidate had reached 270 in the electoral college, the House of Representatives would have voted on the next president.
The Republican-controlled chamber would most likely have picked Mr Trump.
Mr Trump is due to take office on 20 January.
How does electoral college work?
The institution was set up by America’s founding fathers as a compromise between allowing Congress and the people to elect the president.
Technically, Americans cast votes on election day for electors, not the candidates themselves.
The electors are mostly elected officials or party functionaries, and are generally unknown to the public.
There are 538 in all, one for each member of Congress, plus three for District of Columbia.
Although Democrat Hillary Clinton secured almost three million more votes from the public, Mr Trump won the majority of electors – 306.