The Republican Party’s post-mortem after Mitt Romney lost his presidential bid to Barack Obama in 2012 was brutally straightforward: Expand the tent or risk extinction. “We need to campaign among Hispanic, black, Asian and gay Americans and demonstrate we care about them, too,” party leaders wrote. That playbook is gone, burned and buried, and it is not going to be easy to retrieve. The Republican Party is now the party of President Donald Trump. The dark politics of anger, division and fear were on display in campaigns across the country this year, as Republican candidates for Congress and governor — and fringe groups who support them — embraced the racially inflammatory brand of politics that Trump unleashed in 2016.

With the presidential campaign of 2020 effectively underway on Wednesday, there is little reason to think Trump will back away from a tactic that clearly rallies his base.

And as he showed his party in the closing days of the midterms, there may be no way for Republicans to escape his shadow.

“He’s tapped into something really powerful and really ugly in the American electorate,” said Julian E. Zelizer, a historian at Princeton University, “and it’s going to be hard to put that back into the bottle.”

In some respects, the strategy appeared to have worked. In Indiana, Republican Senate candidate Mike Braun crushed the Democrat, Sen. Joe Donnelly. Braun, a businessman and former state legislator, branded Donnelly “Mexico Joe” and wrapped his arms around Trump, who rallied voters in Indiana on Monday by telling them, “If you want more caravans, if you want more crime, vote Democrat tomorrow.”

In Tennessee, another Trump acolyte, Rep. Marsha Blackburn, won her Senate race against Phil Bredesen, a Democrat and former governor. Blackburn made stopping unauthorized immigration a central theme of her race. One Blackburn advertisement, rated “Mostly False” by the fact-checking website PolitiFact, showed shadowy images of young men, presumably crossing the border, and told voters that Bredesen “lured illegal immigrants” to Tennessee.

But some Republicans apparently paid a price.

In heavily Hispanic South Florida, Rep. Carlos Curbelo, a Republican who distanced himself from Trump’s stance on immigration, lost his House seat to Democrat Debbie Mucarsel-Powell. And in Michigan, Democrat Haley Stevens had a healthy lead in her House race against Lena Epstein, a Republican businesswoman and Trump ally.

Candidates across the country cast their lots with Trump this year. In Florida, the Republican candidate for governor, Ron DeSantis, warned voters not to “monkey this up” by electing his black Democratic opponent, Andrew Gillum. In California, Rep. Duncan Hunter, a Republican indicted on federal charges of misusing campaign funds, ran an ad characterizing his Democratic opponent, Ammar Campa-Najjar, as a terrorist sympathizer because of his family ties. Campa-Najjar’s late grandfather was a Palestinian leader who Israel believed was involved in the 1972 massacre of Israeli Olympic athletes in Munich.

In Arkansas, a political action committee calling itself Black Americans for the President’s Agenda released a radio ad using racist caricatures in an effort to court black voters. In Georgia, a white supremacist group paid for robocalls that described Stacey Abrams, a Democrat who was vying to become the nation’s first black female governor, as a “Negress” and a “poor man’s Aunt Jemima.”

And all of that was before this week, when the Trump campaign produced an anti-immigration ad that was so widely seen as racist that even Fox News refused to run it.

Racially charged messaging is not new. Ian F. Haney Lopez, a professor at the University of California, Berkeley, who wrote the book “Dog Whistle Politics,” said the 2018 campaign is the culmination of a more than “50-year pattern,” dating back to the presidential campaign of Barry Goldwater, a Republican. President Richard Nixon’s “Southern strategy” courted white segregationists and effectively drove black Americans to the Democratic Party.

Other presidential candidates have since dabbled in racial politics: Ronald Reagan lauded states’ rights in a 1980 speech in Neshoba County, Miss. In 1988, when George Bush was running for the White House against Michael Dukakis, Bush backers ran an ad spotlighting Willie Horton, a black convicted murderer who raped a white woman while furloughed from prison during Dukakis’ time as governor.

But, Zelizer noted, Reagan backed away from the speech and Bush distanced himself from the ad when each man faced criticism. By contrast, he said, “what President Trump keeps doing is, each time there is criticism, he comes right back in more aggressive fashion.”

That strategy has its limits. Last year in Virginia, Ed Gillespie, a former chairman of the Republican National Committee who once urged his party to avoid the “siren song” of anti-immigrant rhetoric, lost his bid for governor after a campaign that adopted Trump’s cultural and racially tinged messaging, including advertisements featuring tattooed Salvadoran prisoners meant to be members of the gang MS-13, a frequent target of the president.

For the party, the long-term risks are obvious. The country’s demographics are changing: Minority members now make up a majority in five states — Hawaii, New Mexico, California, Texas and Nevada — as well as the District of Columbia. Census officials predict that by 2027, minority members will outnumber whites among young voters ages 18-29.

“Their current messaging does not address the aspirations of many immigrants and young voters, and that’s the future,” said Tom Davis, a retired congressman and former chairman of the National Republican Congressional Committee. “Should that continue, it’s a demographic death wish.”

Davis, though, argued that what is happening in 2018 is nothing more than the usual end-of-campaign-season hardball politicking. Jack Kingston, a former Republican congressman from Georgia, said Democrats engaged in their own brand of racially tinged politics. He pointed to a speech given by Oprah Winfrey at a town hall for Abrams in which Winfrey, harking back to the days when black Americans did not have the right to vote, told a black crowd that failing to show up at the polls would be “dishonoring your family.”

“Oprah had a very deliberate racial message,” Kingston said.

Kingston said if he had his druthers, Republicans would have centered their message on the economy, and not closed out the campaign with dire warnings about caravans of immigrants.

“We don’t have to use any racial language. We have the lowest unemployment rates in history for African-Americans and Hispanics,” he said. “But I also know that any time any of us second-guess President Trump on messaging, we lose.”