HUNTSVILLE, Alabama (Reuters) - President Donald Trump injected himself into a bitter U.S. Senate primary fight in Alabama on Friday, putting to the test his ability to enlist his anti-establishment voters to come to the aid of an endangered Republican incumbent.

U.S. President Donald Trump speaks at a campaign rally for Senator Luther Strange in Huntsville, Alabama, U.S. September 22, 2017. REUTERS/Aaron P. Bernstein

Trump spoke at a rally in Huntsville, Alabama, on behalf of Senator Luther Strange, who was appointed after the seat was left vacant when Jeff Sessions was named Trump’s attorney general.

Strange is trying to ward off a challenge from Roy Moore, an arch-conservative former state Supreme Court justice, in a runoff election next week. Polls show the race to be close.

Trump appeared on stage as the latest Republican effort to repeal Obamacare looked to be faltering after Republican Senator John McCain announced his opposition to a measure to repeal and replace the healthcare law. McCain’s opposition could spell doom for the bill, which the Senate may vote on it next week, because Republicans can afford to lose few votes among their own.

When Trump mentioned McCain’s name in front of the arena crowd of more than 7,000, attendees booed lustily.

Trump expressed optimism that the bill could still pass. “We’re going to do it eventually,” he said.

He also continued to engage in a rhetorical sparring match with North Korea leader Kim Jong Un, again referring to him as “Rocket Man” to the crowd’s cheers.

“We can’t have madmen out there shooting rockets all over the place,” Trump said.

The evening was reminiscent of the raucous campaign rallies that helped define Trump’s insurgent presidential candidacy, and the president’s popularity in this region appeared undiminished. As he has frequently done in such settings, he spent a significant portion of his remarks discussing his surprise victory last November.

Slideshow ( 10 images )

He also again rejected any suggestion that his triumph was aided by Russian interference in the election.

“Russia did not help me. That I can tell you,” Trump said. “Are there any Russians in the audience?”

Trump, however, was in Huntsville not to back the maverick candidate Moore, but instead the establishment favorite, Strange.

A win by Moore in Alabama could embolden other insurgent candidates to challenge Republican incumbents in next year’s congressional elections, and perhaps give an edge to Democrats in some of those races.

Trump’s involvement in the Alabama race could help bolster his strained relationship with Senate Majority Leader Mitch McConnell, whose help the president needs to advance his agenda on taxes, healthcare and immigration.

McConnell has strongly supported Strange, viewing him as a reliable vote to further the Republican Party’s legislative agenda.

Hours before Trump was due to arrive in Alabama, his housing secretary, Ben Carson, issued a statement in support of Moore as “truly someone who reflects the Judeo-Christian values that were so important to the establishment of our country.”

“I wish him well and hope everyone will make sure they vote on Tuesday,” Carson said, stopping short of asking people in Alabama to vote for Moore.

Republican leaders fear that candidates who are too far to the right could lose to Democrats, who are seeking to wrest control of the House and the Senate in the 2018 midterm elections.

Strange, 64, and dubbed “Big Luther” in reference to his 6-foot-9 stature, has been backed by nearly $9 million of advertising from a McConnell-allied political action committee.

Trump implored the crowd to back Strange so that “we can defend your interests, fight for your values, and always put America first.”

Moore, 70, is a religious conservative who twice lost his position as the state’s top judge. He was ousted in 2003 after refusing to comply with a federal court order to remove a Ten Commandments monument from the state Supreme Court building. He is also known for his opposition to gay rights.

He is popular with many of the same conservative voters who backed Trump last November.

“A lot of people love Trump and love Roy Moore,” said Ford O’Connell, a Republican strategist who has worked for Strange in Alabama.

Trump’s embrace of Strange has put him at odds with his former adviser Steve Bannon and the nationalistic wing of the party.

Breitbart, the conservative news site that Bannon oversees, has repeatedly attacked Strange as a Washington insider while praising Moore as an outsider in the mold of Trump when he was a presidential candidate.