– In the run-up to the midterm elections, President Donald Trump warned of an “invasion” of murderous thugs and potential terrorists pouring across the southern border. He called for ending birthright citizenship. He demonized House Minority Leader Nancy Pelosi as dangerous and destructive. He promised to cut taxes on the middle class.

But in the nearly two weeks since the elections, Trump has abruptly changed tune — ditching the messages that advisers now acknowledge were crafted in a Hail Mary play to excite his base and stave off Republican losses.

Gone from the president’s talking points are dire threats about the caravan of Central American migrants that he had described as imminent and life-threatening, or the executive order he promised to sign ending the constitutional right to citizenship for children born in the United States to undocumented immigrants, or the phantom 10 percent middle-class tax cut that he said would pass so easily.

Now that Democrats have seized the House majority, the president has added to his repertoire talk about cutting deals with Pelosi, who is trying to line up the votes to become speaker again. He pledged his support last week for bipartisan criminal justice reform legislation. And he is telling advisers that he wants an infrastructure package soon — and that he thinks Democrats will go along with one.

Trump is fixated anew on the Russia probe, huddling with his lawyers this week to prepare written testimony for special counsel Robert Mueller and pecking out all-caps tirades on Twitter. “A TOTAL WITCH HUNT LIKE NO OTHER IN AMERICAN HISTORY!” he wrote last week.

Trump’s shift in rhetoric and policy priorities is striking enough that this period of his presidency could be divided in two parts: Before and after Nov. 6. “The whole point of effective rhetoric is to adapt to changing situations, and he is adapting,” said Martin Medhurst, a Baylor University professor of rhetoric. “He’s doing it in a not terribly artful way, but he is adapting. … Governing awaits.”

In the wake of the election, Trump boasted in calls with outgoing House Speaker Paul Ryan and advisers that he believed his performance on the campaign trail helped Republicans — even though voters in suburbs across the country voted for Democrats.

The president also told his advisers that he wants to strike a quick deal with Pelosi and that working with the Democrats could help keep their investigations at bay, according to people familiar with the conversations. Trump also has been telling advisers that voters like the word “bipartisan.”

Sen. Lindsey Graham, R-S.C., a Trump confidant, said the president is talking a lot privately about a bipartisan infrastructure bill. “A divided government presents challenges and opportunities,” ­Graham said. “I think he’s pretty excited about what we can do, about the dealmaking.”

Trump has proved over the years to be a shape-shifter when it is expedient, changing priorities or reversing his policy positions altogether to adapt to the political winds. Current and former advisers say the president believes his support among his base is so strong that he has cover to make deals as he sees fit, including with Democrats.

Most presidents turn from campaign mode to governing mode, dialing down some of their partisan rhetoric in the interest of accomplishing things in office. But Trump’s shift has been unusually clear-cut, in part because his talk on the campaign trail was so hyperbolic and often unmoored from reality.

The centerpiece of Trump’s closing message to voters was the caravan, even though it was made up of unarmed families fleeing violence in their homelands, seeking asylum and traveling by foot hundreds of miles away from the U.S.-Mexico border.

Trump beat his drum about the migrants on Twitter, at his “Make America Great Again” rallies and in a blitz of interviews. He deployed thousands of U.S. troops to the border region to prepare for what he termed an “invasion.” And his political team released an advertisement that major TV networks deemed too racist to air that featured a Latino undocumented immigrant convicted of killing two police officers.

“If you don’t want America to be overrun by masses of illegal aliens and giant caravans, you better vote Republican,” Trump said at a rally five days before the election in Columbia, Mo.

Trump’s advisers and allies acknowledge that the president’s focus on the caravan was a campaign messaging tool. And since the election, he has largely stopped sounding the alarm — although he tweeted over the weekend about the caravan and urged the migrants to “Go home!”

“American politicians have always thinly veiled their tactics and come up with reasons why they are changing directions or switching positions, and with Trump, there is no subtlety, and there is no thin veil,” said one former White House official, who requested anonymity. “It’s raw power politics. It’s, ‘I’m doing this because it’s election time, and I know it will generate energy for my base, and now the election’s over, so I’m shifting in x, y and z way.’ ”

If his recent public utterances are any indication, Trump seems to have lost interest in the caravan relative to the run-up to the election — even though troops remain stationed at the border, where they were visited last week by Defense Secretary Jim Mattis and Homeland Security Secretary Kirstjen Nielsen. Though Trump’s advisers say illegal immigration remains top of mind for the president, he does not see a political benefit at the moment in talking about it.

Retired four-star Army Gen. Barry McCaffrey said, “It was without question a political stunt for the midterm elections. There was no — zero — national security issue at stake.”