Donald Trump was easily affirmed the winner of the 2016 election after the Electoral College met in state capitals across the country Monday, ending last-ditch attempts by activists in both parties to deny him the presidency.

A vote of Texas’ 38 electors in Austin gave Mr. Trump the necessary Electoral College votes to become president in January, ensuring his victory over Democrat Hillary Clinton. Despite intense pressure on electors across the country to reject Mr. Trump, he easily won more than the 270 electoral votes needed to become president.

“This election represents a movement that millions of hard working men and women all across the country stood behind and made possible,” said Mr. Trump in a statement. “With this historic step we can look forward to the bright future ahead. I will work hard to unite our country and be the President of all Americans.”

Monday’s Electoral College proceedings drew a record number of votes for candidates other than Mr. Trump or Mrs. Clinton. That reflected the lingering deep divisions within the country that played out during an election season in which Mr. Trump won more electoral votes, but trailed Mrs. Clinton in the popular vote. At least seven electors defied the will of the voters in their states—a number not seen in roughly a century and a half.

Two Texas Republican electors cast ballots for Ohio Gov. John Kasich and former Texas Republican Rep. Ron Paul. On the Democratic side, four Washington state electors refused to cast ballots for Mrs. Clinton and her running mate, Sen. Tim Kaine. Three voted for former Secretary of State Colin Powell, while one cast a ballot for Native American activist Faith Spotted Eagle. In Hawaii, one Democratic elector also cast a ballot for Vermont Sen. Bernie Sanders.

In the vice-presidential vote, the Washington vote was even more unusual, with electors casting votes for a trio of female U.S. senators: Democrats Elizabeth Warren of Massachusetts and Maria Cantwell of Washington, as well as Susan Collins, a Republican from Maine. Another elector cast a ballot for Winona LaDuke, an environmental activist. One Texas Republican voted for former Republican presidential candidate Carly Fiorina on the vice-presidential ballot. Another Hawaii elector also voted for Ms. Warren.

How Trump’s Election Predictions Came True President-elect Donald Trump made eye-popping predictions during the campaign that were ultimately proven correct in America's 2016 presidential election. Here's a look back at the outsider candidate's crystal ball. Photo: AP

Several other attempts by electors to cast ballots for alternative candidates were unsuccessful. Democratic electors in Colorado and Maine tried to cast votes for Mr. Sanders. In Maine, the elector was ordered to vote again, while in Colorado the elector was replaced with an alternate.

The vote of the Electoral College showed that Mr. Trump has broadly unified the Republican Party behind him in the weeks since his election. In a new Wall Street Journal/NBC News poll, some 75% of Republicans had a positive view of Mr. Trump, up from 57% in the weeks before the election. Views of the Republican Party among GOP voters also improved markedly. And some 68% of Republicans said they believe the economy will improve in the next year, up from only 14% a year ago and far higher than the 19% of Democrats who foresee a stronger economy.

The vote from the Electoral College affirms the results of November’s election, which saw Mr. Trump eke out a narrow victory across a series of swing states. Mrs. Clinton won the popular vote, amassing a nearly 3 million vote lead over Mr. Trump nationwide. But he won a plurality of the vote in enough states to accumulate 306 electoral votes to Mrs. Clinton’s 232.

The Electoral College votes will be officially tallied in a joint session of Congress in early January.

Typically just a formality, this year’s Electoral College vote attracted an outsize amount of attention after a group of mostly Democratic electors made a late push to block Mr. Trump from assuming office, arguing that the body has a constitutional duty to act independently of the will of the voters in extraordinary circumstances.

Protesters holding signs that spell the word 'Democracy' outside the Massachusetts Statehouse in Boston on Monday. Photo: CJ Gunther/European Pressphoto Agency

Protesters gathered in several state capitals to encourage electors to reject Mr. Trump. Members of the Electoral College reported being deluged with correspondence and threats in the run-up to the vote from people urging them to reconsider their vote for Mr. Trump. The people cited such reasons as Mrs. Clinton’s popular-vote win, Mr. Trump’s temperament, and the judgment by the Central Intelligence Agency that Russian-linked hackers targeted the Democratic Party in an attempt to boost Mr. Trump.

A mostly Democratic group of electors called themselves the Hamilton Electors, named after a founding father, Alexander Hamilton, who helped design an independent Electoral College. The electors mounted a campaign to try to rally around another Republican to make it impossible for any candidate to get the required 270 votes. In that scenario, the election would go to the House of Representatives for resolution.

For example, Chris Suprun, a Texas Republican elector, said he couldn’t cast a ballot for Mr. Trump, and instead voted for Mr. Kasich in Monday’s proceedings. “For the rest of us Americans, his presence in the Oval Office represents a crisis for the Constitution, the economy, and the country. I’ve said it before and I’ll say it again, Trump is unfit to be president,” Mr. Suprun said in a statement after the vote.

The Electoral College, now comprised of 538 members representing 50 states and the District of Columbia, was originally designed to act as an independent body. Some states require their electors to vote the same way as the voters in each state, but those laws have never been tested.

There have occasionally been “faithless” electors who ignore the will of the voters in their states, but they have never swung the outcome of an election.

The last election to draw major numbers of faithless presidential electors was 1872, when the Democratic presidential candidate died shortly after Election Day. Prior to that, the 1808 election was the last time that so many presidential electors defected. Defections on the vice-presidential vote have historically been much more common.

Corrections & Amplifications:

Alexander Hamilton was an American statesman and founding father of the U.S. An earlier version of this article incorrectly stated he was president. (Dec. 19)

Write to Byron Tau at byron.tau@wsj.com