U.S. President-elect Donald Trump arrives to speak during a USA Thank You Tour event at Giant Center in Hershey, Pennsylvania, U.S., December 15, 2016. REUTERS/Lucas Jackson

WASHINGTON ―The Electoral College formally selected Donald Trump as U.S. president on Monday, even as several electors bucked their states by opting to cast their presidential ballots for someone other than Trump or Hillary Clinton.

Members of the Electoral College met in their respective state Capitols to vote for the presidential and vice presidential candidates for whom they had pledged to vote earlier this year. Many electors, however, are not legally bound to vote for a specified candidate. Some electors ― known as “faithless electors” ― have in the past voted against their political party or abstained from voting altogether.

Trump hit the necessary threshold of 270 electoral votes after Texas’ representatives cast their ballots. At the end of the day, Trump had 304 electoral votes to Clinton’s 227, and seven votes were cast for others. Congress will meet in a joint session on Jan. 6 to officially count the Electoral College votes.

Maine Democratic elector David Bright announced in advance that he would cast his ballot for Sen. Bernie Sanders (I-Vt.), who lost to Clinton in the Democratic presidential primary.

“I cast my vote for Bernie Sanders not out of spite, or malice, or anger, or as an act of civil disobedience,” Bright said in a statement. “I mean no disrespect to our nominee. I cast my vote to represent thousands of Democratic Maine voters ― many less than a third my age ― who came into Maine politics for the first time this year because of Bernie Sanders.”

Maine is one of 29 states plus the District of Columbia that require its electors to cast their ballots for the person the elector is tied to ― in this case Clinton. Bright could face a fine for his actions, but no elector has been penalized in the past.

Chris Suprun, a Republican elector from Texas, had said he would vote for Ohio Gov. John Kasich (R). In an op-ed earlier this month in The New York Times, Suprun said the president-elect “shows daily he is not qualified for office” and called on fellow electors to “do their job” and unify around an “honorable and qualified” alternative.

Suprun further explained his decision to vote for Kasich in a piece Monday in The Hill.

“Ronald Reagan did not win the Cold War so that Vladimir Putin could pick our next president less than 50 years later,” he said.

Despite these defections, Trump’s formal election was never truly in doubt. He will be one of just five presidents to win the White House while losing the popular vote (since it was tracked starting in 1824). Trump trails Clinton by more than 2.5 million votes, the biggest margin in raw numbers by which a president has lost the popular vote.

To change the election results, 38 Trump electors would have had to defy their party and cast a ballot for another candidate. That was extremely unlikely. Nevertheless, activists sought to sway Republican electors to vote against the president-elect, citing the Electoral College as a necessary component of the federal government’s system of checks and balances.

Harvard Law School professor Larry Lessig, one of those activists, offered free legal aid to any electors breaking with their state in hopes of derailing Trump’s path to the White House.

“The motivation was the recognition that there were going to be a lot of electors who were considering what we believe is their constitutional right, to vote their conscience,” Lessig said.