WASHINGTON — Donald Trump was elected the 47th president of the United States on Wednesday, an extraordinary comeback for a former president who refused to accept defeat four years ago, sparked a violent insurrection at the U.S. Capitol, was convicted of felony charges and survived two assassination attempts.

With a win in Wisconsin, Trump cleared the 270 electoral votes needed to clinch the presidency. He won Michigan on Wednesday afternoon, sweeping the “blue wall” along with Pennsylvania — the one-time Democratic-leaning swing states that all went for Trump in 2016 before flipping to President Joe Biden in 2020.

His Democratic rival, Vice President Kamala Harris, called Trump on Wednesday afternoon to concede the race and congratulate him. A short time later, Biden also called Trump to congratulate him and to invite the president-elect to the White House, formally kicking off the transition ahead of Inauguration Day, the White House said. Biden also called Harris.

Foreign leaders called Trump too, including Israeli Prime Minister Benjamin Netanyahu and French President Emmanuel Macron.

The victory validates Trump’s bare-knuckles approach to politics. He had attacked Harris in deeply personal — often misogynistic and racist — terms as he pushed an apocalyptic picture of a country overrun by violent migrants. The coarse rhetoric, paired with an image of hypermasculinity, resonated with angry voters – particularly men – in a deeply polarized nation.

“I want to thank the American people for the extraordinary honor of being elected your 47th president and your 45th president,” Trump told throngs of cheering supporters in Florida even before his victory was confirmed.

In state after state, Trump outperformed what he did in the 2020 election while Harris failed to do as well as Joe Biden did in winning the presidency four years ago. Upon taking office again, Trump will work with a Senate that will now be in Republican hands, while control of the House hadn’t been determined.

“We’ve been through so much together, and today you showed up in record numbers to deliver a victory,” Trump said. “This was something special and we’re going to pay you back,” he said.

The U.S. stock market, Elon Musk’s Tesla, banks and bitcoin all stormed higher Wednesday, as investors looked favorably on a smooth election and Trump returning to the White House. In his second term, Trump has vowed to pursue an agenda centered on dramatically reshaping the federal government and pursuing retribution against his perceived enemies.

The results cap a historically tumultuous and competitive election season that included two assassination attempts targeting Trump and a shift to a new Democratic nominee just a month before the party’s convention. Trump will inherit a range of challenges when he assumes office on Jan. 20, including heightened political polarization and global crises that are testing America’s influence abroad.

His win against Harris, the first woman of color to lead a major party ticket, marks the second time he has defeated a female rival in a general election. Harris, the current vice president, rose to the top of the ticket after Biden exited the race amid alarm about his advanced age. Despite an initial surge of energy around her campaign, she struggled during a compressed timeline to convince disillusioned voters that she represented a break from an unpopular administration.

Trump is the first former president to return to power since Grover Cleveland regained the White House in the 1892 election. He is the first person convicted of a felony to be elected president and, at 78, is the oldest person elected to the office. His vice president, 40-year-old Ohio Sen. JD Vance, will become the highest-ranking member of the millennial generation in the U.S. government.

There will be far fewer checks on Trump when he returns to the White House. He has plans to swiftly enact a sweeping agenda that would transform nearly every aspect of American government. His GOP critics in Congress have largely been defeated or retired. Federal courts are now filled with judges he appointed. The U.S. Supreme Court, which includes three Trump-appointed justices, issued a ruling this year affording presidents broad immunity from prosecution.

Trump’s language and behavior during the campaign sparked growing warnings from Democrats and some Republicans about shocks to democracy that his return to power would bring. He repeatedly praised strongman leaders, warned that he would deploy the military to target political opponents he labeled the “enemy from within,” threatened to take action against news organizations for unfavorable coverage and suggested suspending the Constitution.

Some who served in his White House, including Vice President Mike Pence and John Kelly, Trump’s longest-serving chief of staff, either declined to endorse him or issued dire public warnings about his return.

While Harris focused much of her initial message around themes of joy, Trump channeled a powerful sense of anger and resentment among voters.

He seized on frustrations over high prices and fears about crime and migrants who illegally entered the country on Biden’s watch. He also highlighted wars in the Middle East and Russia’s invasion of Ukraine to cast Democrats as presiding over – and encouraging – a world in chaos.

It was a formula Trump perfected in 2016, when he cast himself as the only person who could fix the country’s problems, often borrowing language from dictators.

“In 2016, I declared I am your voice. Today I add: I am your warrior. I am your justice. And for those who have been wronged and betrayed, I am your retribution,” he said in March 2023.

This campaign often veered into the absurd, with Trump amplifying bizarre and disproven rumors that migrants were stealing and eating pet cats and dogs in an Ohio town. At one point, he kicked off a rally with a detailed story about the legendary golfer Arnold Palmer in which he praised his genitalia.

One defining moment came in July when a gunman opened fire at a Trump rally in Butler, Pennsylvania. A bullet grazed Trump’s ear and killed a supporter. His face streaked with blood, Trump stood and raised his fist in the air, shouting “Fight! Fight! Fight!” Weeks later, a second assassination attempt was thwarted after a Secret Service agent spotted the barrel of a gun poking through the greenery while Trump was playing golf.

Trump’s return to the White House seemed unlikely when he left Washington in early 2021 as a diminished figure whose lies about his defeat sparked a violent insurrection at the U.S. Capitol. He was so isolated then that few outside of his family bothered to attend the send-off he organized for himself at Andrews Air Force Base, complete with a 21-gun salute.

Democrats who controlled the U.S. House quickly impeached him for his role in the insurrection, making him the only president to be impeached twice. He was acquitted by the Senate, where many Republicans argued that he no longer posed a threat because he had left office.

But from his Mar-a-Lago resort in Florida, Trump — aided by some elected Republicans — worked to maintain his political relevance. Rep. Kevin McCarthy, the California Republican who then led his party in the U.S. House, visited Trump soon after he left office, essentially validating his continued role in the party.

As the 2022 midterm election approached, Trump used the power of his endorsement to assert himself as the unquestioned leader of the party. His preferred candidates almost always won their primaries, but some went on to defeat in elections that Republicans viewed as within their grasp. Those disappointing results were driven in part by a backlash to the Supreme Court ruling that revoked a woman’s constitutional right to an abortion, a decision aided by Trump-appointed justices. The midterm election prompted questions within the GOP about whether Trump should remain the party’s leader.

But if Trump’s future was in doubt, that changed in 2023 when he faced a wave of state and federal indictments for his role in the insurrection, his handling of classified information and election interference. He used the charges to portray himself as the victim of an overreaching government, an argument that resonated with a GOP base that was increasingly skeptical — if not outright hostile — to institutions and established power structures.

Special counsel Jack Smith was evaluating Wednesday how to wind down the two federal criminal cases against Trump.

Florida Gov. Ron DeSantis, who challenged Trump for the Republican nomination, lamented that the indictments “sucked out all the oxygen” from the GOP primary. Trump easily captured his party’s nomination without participating in a debate against DeSantis or other GOP candidates.

With Trump dominating the Republican contest, a New York jury found him guilty in May of 34 felony charges in a scheme to illegally influence the 2016 election through a hush money payment to a porn actor who said the two had sex. He faces sentencing this month, though his victory poses serious questions about whether he will ever face punishment.

He also has been found liable in two other New York civil cases: one for inflating his assets and another for sexually abusing advice columnist E. Jean Carroll in 1996.

Trump is subject to additional criminal charges in an election-interference case in Georgia that has become bogged down. On the federal level, he’s been indicted for his role in trying to overturn the results of the 2020 election and improperly handling classified material. When he becomes president, Trump could appoint an attorney general who would erase the federal charges.

As he prepares to return to the White House, Trump has vowed to swiftly enact a radical agenda that would transform nearly every aspect of American government. That includes plans to launch the largest deportation effort in the nation’s history, to use the Justice Department to punish his enemies, to dramatically expand the use of tariffs and to again pursue a zero-sum approach to foreign policy that threatens to upend longstanding foreign alliances, including the NATO pact.

When he arrived in Washington 2017, Trump knew little about the levers of federal power. His agenda was stymied by Congress and the courts, as well as senior staff members who took it upon themselves to serve as guardrails.

This time, Trump has said he would surround himself with loyalists who will enact his agenda, no questions asked, and who will arrive with hundreds of draft executive orders, legislative proposals and in-depth policy papers in hand.

Colvin reported from West Palm Beach, Florida.