Republicans who once questioned President Trump’s competence or called him a “jackass” have spent recent weeks singing his praises and joining him on Air Force One as the president works to repair strained relationships on Capitol Hill ahead of the midterms.

Facing the prospect of a Democratic wave in November, the White House and GOP lawmakers have already begun to bridge their past differences in preparation for the political battle they will fight together over the next 10 months.

Trump spent the first days of 2018 huddling with GOP congressional leaders at Camp David, where they presented a united front despite the feuds Trump has waged with many of the party’s top leaders.

“The [president] had a very good experience in dealing with Republican House and Senate leadership and rank and file – delivering on generational tax reforms,” said Bradley Blakeman, a Republican strategist. “All parties appreciate that 2018 is a year of political consequence with the midterms looming this November, and that means Republicans must have a record of accomplishment to run on. This is about delivering on campaign promises and self preservation.”

“Republicans must hang together, or they will hang separately,” Blakeman added.

Trump and many congressional Republicans have endured shaky relationships that often devolved over the past year into Twitter fights or trading barbs in the media. Those relationships reached their nadir over the summer, when a push for healthcare reform fell apart after months of negotiations, and Senate Majority Leader Mitch McConnell blamed Trump’s “excessive expectations” for driving the failure.

McConnell and Trump have appeared much friendlier toward each other since McConnell successfully shepherded a tax reform bill through the upper chamber in December, fulfilling a top White House priority for 2017.

And McConnell quickly took Trump’s side in a feud between the president and Steve Bannon, his former chief strategist, earlier this month. The Senate majority leader, who has criticized Bannon’s plans to mount primary challenges against Republican incumbents and candidates backed by McConnell, tweeted a picture of himself smiling giddily as Trump issued a statement denouncing Bannon on Jan. 3.

“It is a recognition by both President Trump and his Republican congressional critics that they need each other for political survival,” said Ford O’Connell, a Republican strategist.

“When he does things that are not seen as presidential or the way that necessarily a lot of folks would play something, they’re not running to TV booths anymore to criticize him,” O’Connell said of congressional Republicans. “They recognize that if he goes away or if they lessen his power, they might be next on the chopping block. But if he succeeds, they succeed.”

Sen. Bob Corker, R-Tenn., raised eyebrows last week when he joined Trump on a trip to his home state for an agriculture event. While members traditionally accompany the president on such visits to their home states, the trip was widely viewed as evidence that the animosity between Trump and Corker had begun to ease.

Trump and the Tennessee Republican clashed bitterly in 2017, when Corker became a leading Republican critic of the president before falling in line behind him to support the GOP tax bill.

“The president has not yet been able to demonstrate the stability nor some of the competence that he needs to demonstrate in order to be successful," Corker said in August.

The following week, White House press secretary Sarah Sanders called Corker’s comments “ridiculous and outrageous.”

Tensions between Corker and Trump appeared to simmer throughout the fall, but boiled over shortly after the Tennessee Republican announced he would not seek a third term in 2018.

Trump claimed via Twitter in October that Corker had “begged” the president for his endorsement while weighing whether to run for reelection this year, prompting Corker to fire back with the claim that West Wing aides ran the White House like an “adult daycare center.”

Trump has even reached out to a former object of his scorn, Mitt Romney, ahead of what could be a hotly contested race for a Senate seat in Utah.

The president reportedly called Romney earlier this month to encourage him to run for the seat Republican Sen. Orrin Hatch will leave vacant this year upon retirement. The call could mark a period of detente between the two men, who have exchanged harsh words in the past.

One GOP senator with whom Trump once quarreled has become a top defender of the administration in recent weeks: Sen. Lindsey Graham, R-S.C.

Graham pushed back against criticism last week of Trump’s claim to be a “very stable genius” in the face of questions about his mental fitness. The former Trump critic, who ran against the president in the GOP primaries in 2016, reminded the hosts of “The View” on Jan. 8 that Trump managed to beat a well-qualified field of primary opponents “like a drum.”

“In my view, he is my president, and he’s doing a really good job on multiple fronts,” Graham said.

Since the frosty days of the campaign, during which time Graham called Trump a “jackass,” the South Carolina Republican and Trump have forged an unlikely bond over golf and political strategizing that has given to rise to a key alliance for the president on Capitol Hill.