President-elect Donald Trump. Drew Angerer/Getty Images Donald Trump secured the necessary 270 electoral votes on Monday to formally be elected the 45th US president.

While millions of people had petitioned the 538 members of the Electoral College to make Hillary Clinton president instead, and tens of thousands took to the streets in the weeks after the election to protest Trump's win, the official results came in as expected.

Trump won the popular vote in 30 states and one of Maine's districts — that state, along with Nebraska, splits up its electors by district — giving him an expected 306 electoral votes. He needed 270 to win.

While Clinton won nearly 2.9 million more votes than he did overall because she carried population-heavy states like California and New York, she won the popular vote in only 20 states plus Washington, DC, giving her an expected 232 electoral votes.

"We did it!" Trump tweeted after the results were announced. "Thank you to all of my great supporters, we just officially won the election (despite all of the distorted and inaccurate media)."

The expected electoral results based on the popular vote. Business Insider/Andy Kiersz/Skye Gould

Were there any 'faithless' electors?

Hillary Clinton publicly conceded the presidential election at the New Yorker Hotel on November 9. Justin Sullivan / Getty Despite the protests, only two electors broke ranks to vote against Trump — but Clinton lost five electoral votes.

The final electoral tally was 304 votes for Trump, 227 for Clinton, and seven for other candidates.

Members of the Electoral College who go against their state or district's popular vote are rather ominously called "faithless electors."

Instead of voting for Trump in Texas, one elector cast his ballot for Ron Paul, and another voted for Republican presidential candidate John Kasich.

On the Clinton side, one elector in Hawaii voted for Democratic presidential candidate Bernie Sanders instead. In Washington state, three electors voted for former Secretary of State Colin Powell and one voted for Native American elder Faith Spotted Eagle.

Others tried not to vote for Clinton, too. One elector in Minnesota tried to vote for Sanders but was replaced with another who voted for her. An elector in Maine tried to vote for Sanders, too, but switched his vote to Clinton after a second round of voting. In Colorado, an elector voted for Kasich before being replaced with an elector who did vote for Clinton.

To become president, Clinton would have needed 38 electors in states that Trump won to vote for her.

What kept electors from turning faithless?

Pennsylvania elector Carolyn Bunny Welsh holding her ballot for Trump before casting it at the Pennsylvania State Capitol in Harrisburg on Monday. REUTERS/Jonathan Ernst Several barriers are in place preventing electors from turning "faithless."

Thomas Neale, an expert in American government and the Electoral College for the Congressional Research Service, found that only eight electors had been faithless from 1900 to 2012.

Thirty states plus DC have laws on the books "binding" their electors to vote for the candidate who won the state's popular vote, and electors are usually selected by the political parties in each state, Neale told Business Insider in November.

The faithless electors in Washington will each have to pay a $1,000 fine, according to state law. But the other faithless electors won't face a penalty because Texas doesn't bind its electors and Hawaii state law doesn't specify a fine.

As a final check on the electoral process, members of Congress can formally protest faithless elector votes, and have them thrown out, when they officially count the ballots in a joint session on January 6.