Republican leaders are encouraging President Trump to intervene in competitive primaries, concluding that he is a powerful force to energize GOP voters and help the party hold its Senate majority in the midterm elections.

The decision is a notable reversal for top GOP senators, some of whom feuded with Trump during the first year of his presidency and saw his erratic behavior and low approval as potential liabilities.

But they were thrilled Wednesday with the outcome of primaries in three states where their preferred candidates closely aligned with Trump won — thanks to some help from the president.

Republicans said they expected Trump to reprise the role he played in West Virginia, where they argued that his last-minute plea to GOP voters to reject Don Blankenship helped ensure that the former coal executive with a criminal record lost on Tuesday.

“I think the president did an outstanding job, and I think the president will do more of it because he understands the need to win,” said Sen. Cory Gardner of Colorado, the head of the Senate Republican campaign arm.

In Indiana, wealthy businessman Mike Braun captured the GOP nomination running on a Trump-like outsider platform. Rep. James B. Renacci, who had Trump’s endorsement, was the primary victor in Ohio. State Attorney General Patrick Morrisey prevailed in West Virginia.

All three give the GOP formidable opponents against Democratic incumbents in states Trump won handily in 2016.

Both Trump and Senate Majority Leader Mitch McConnell (R-Ky.) took victory laps Wednesday, emboldened by the results.

“Last night was a very big night for the Republican Party,” Trump said at the White House. “Every candidate that we wanted won, and they did very well. There was tremendous enthusiasm.”

Now, Republicans are trying to build on that enthusiasm to preserve their narrow 51-to-49 Senate majority. They are ramping up efforts to defeat Democratic senators in states Trump won, such as Indiana, where the president plans to campaign on Thursday, as well as Florida.

McConnell and Trump have spoken regularly in recent weeks about the elections, with the Senate leader urging the president to promote viable candidates, according to Republicans familiar with the conversations who spoke on the condition of anonymity to discuss private talks.

They also are relying on Fox News to help deliver the GOP message. In the Senate Republicans’ closed-door luncheon Wednesday, McConnell stressed the importance of appearances on Fox News programs, arguing that the key to defeating Blankenship was a sharp turn against the candidate in Fox News coverage in the final two days before the election.

Fox News programs typically draw viewers from two key constituencies: conservative voters critical in low-turnout midterm elections and Trump.

Republicans spoke about the luncheon discussion on the condition of anonymity to freely describe the talk.

At the same time they are trying to flip some Democratic seats, Republicans are trying to protect seats from falling into Democratic hands in Arizona and Mississippi. In those states, controversial Republican contenders are in the mix, posing problems like the ones they faced in West Virginia.

Trump can be a major factor on both fronts, GOP leaders contend. Above all, they said, the party must ensure that the most electable candidates are on the ballot in November. And they are leaning most heavily on Trump to help make that happen.

Trump used his massive Twitter following to warn West Virginia residents not to vote for Blankenship, who had served time in prison for conspiring to violate mine safety regulations after an explosion at one of his company’s mines killed 29 people in 2010.

Morrisey’s win prompted GOP leaders to breathe a sigh of relief.

“Worked out very well. We’ve got a nominee that can win in November,” an upbeat McConnell told reporters in the Capitol.

Morrisey’s victory put his opponent, Democratic Sen. Joe Manchin III, in a defensive posture.

“I’m not running against Morrisey. I’m running for the seat of the United States Senate. Now, if he wants to challenge me and take the seat away, yeah, he’s running against me,” Manchin said. He called Blankenship the only “conservative, West Virginia Republican in that race,” a tacit swipe at Morrisey, who ran for Congress from New Jersey in 2000.

The 10 Democratic Senate incumbents running in the states Trump won have been advised by strategists to focus on undermining Republican efforts to cast them as either liberals or Washington politicians.

“We are obviously living in a polarized cycle in which there is a lot of political tribalism,” said Joe Trippi, a Democratic strategist advising Senate candidates in Mississippi. “Any national politics tends to play into the tribalism because of the president, and that’s why keeping it local and kitchen table issues is so important.”

In states such as Montana, Missouri and Indiana, the Democratic senators have been talking about veterans’ issues. In West Virginia and Ohio, the Democratic senators have been boasting of their efforts to use federal money to backstop coal miner pension and health benefit funds.

Democrats have also developed clear lines of attack to go after the winners of Tuesday’s primary. They will attack Morrisey as a carpetbagger lobbyist and not a true West Virginia native, said people familiar with the plans. As in the primary, he will be criticized for his and his wife’s work for the pharmaceutical industry, which has a poor reputation in the state given the ongoing epidemic of opioid abuse.

In Indiana, Democrats plan to focus on Braun’s brief time in the state legislature to undercut his claim of being an outsider uncorrupted by politics. They will also return to the 2012 playbook used against Republican presidential nominee Mitt Romney by focusing on the complaints of workers at Braun’s factories and the fact that he sells customers some Chinese-made products.

There were signs of enthusiasm on both sides in Tuesday’s races. In Ohio, where both parties held attention-grabbing gubernatorial primaries, there were 827,039 votes cast in the Republican race and just 679,738 votes cast in the Democratic race.

Republicans were pleased about their turnout there, while Democrats were happy that the total Democratic vote statewide was 50 percent higher than it had been in 2014’s primaries.

In West Virginia, Blankenship’s strategy centered on launching relentless and sometimes racial attacks against McConnell and his family. He called McConnell a “swamp captain” and “Cocaine Mitch” and referred to his father-in-law, who was born in China, as a “wealthy China person.”

“Didn’t seem to work too well, did it?” McConnell said.

The party will face similar tests in the coming months in Arizona and Mississippi. Contested Republican fields in those states include controversial candidates who are hostile to McConnell, such as state Sen. Chris McDaniel in Mississippi and former sheriff Joe Arpaio in Arizona.

Trump has not made endorsements in either race.

Last year, after Senate Republicans failed to repeal and replace the Affordable Care Act, relations between McConnell and Trump were bad. There were flashes of anger from other Republican senators, raising doubts about whether both sides could ever cooperate.

But with the election nearing, the relationship has improved, partly thanks to a common goal on both sides: winning.

McConnell said Wednesday that Republicans learned from the mistakes of 2010 and 2012 and have done an effective job of fielding electable Senate contenders more recently.

“In ’14, ’16, ’18, after the malfunctions of 2010 and 2012, we were determined to have nominees on the general election ballot who could actually win,” McConnell said. “Pretty simple. You don’t nominate somebody who’s appealing to the broader audience, you can’t win.”

McConnell said that Alabama was the only place where that did not work out well. In a special election there last year, Republicans nominated Roy Moore, who ran as a hard-right outsider hostile to McConnell. Moore lost a seat that was long under GOP control after The Washington Post reported allegations that he made unwanted sexual advances toward teenage girls when he was in his 30s.

Even after GOP leaders abandoned Moore, Trump campaigned for him.

David Weigel, Paul Kane, Mike DeBonis and Seung Min Kim contributed to this report.