Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — After all else failed, President Donald Trump sided with Roy Moore.

When the Alabama Republican Senate nominee was accused of sexual misconduct with girls in their teens earlier this month, Senate Majority Leader Mitch McConnell, House Speaker Paul Ryan and many other GOP leaders called for Moore to drop his bid. The Republican National Committee, which serves Trump, pulled out of the state. And one of Trump's daughters, Ivanka Trump, said she doesn't doubt the accusers and that "there's a special place in hell for people who prey on children."

None of it worked to push Moore from the race.

Many Republicans concluded that it was better for Moore to lose to Democrat Doug Jones than to sully the GOP's brand — and its chances in next year's midterm elections — by taking a seat in the Senate.

Not Trump. He needs a Republican in that seat — now. His agenda, most notably a tax-code rewrite, is hanging by a thread, and nothing will get easier for him if the Senate Republican caucus shrinks from 52 votes to 51 votes.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

That helps explain why, after nearly two weeks of silence on the matter, Trump jumped into the fray.

"We don't need a liberal person in there," Trump told reporters Tuesday, referring to Jones. The president also pointed out that Moore "totally denies" the allegations against him and left open the possibility that he might campaign for the Republican in Alabama.

Trump's advisers and allies are taking a similar line with regard to the candidate choice.

"It’s pretty logical for Republicans to say if you’re a Republican in Alabama, even a Republican in Alabama who doesn’t want to vote for Roy Moore, you really ought to not vote for the Democrat," said Matt Schlapp, president of the American Conservative Union and a frequent Trump surrogate during the 2016 campaign.

"We want the votes in the Senate to get this tax bill through," White House adviser Kellyanne Conway said on Fox and Friends this week. "Doug Jones in Alabama, folks, don't be fooled. He will be a vote against tax cuts. He is weak on crime. Weak on borders. He is strong on raising your taxes. He is terrible for property owners."

Jones, who suddenly found himself in a competitive race, is attacking Moore over the allegations of sexual misconduct. The narrator in a video released by Jones's campaign Wednesday reads the names of women who have accused Moore of impropriety over a slideshow of their photos.

"They were girls when Roy Moore immorally pursued them," the narrator says. "Now they are women witnesses to us all of his disturbing conduct. Will we make their abuser a U.S. Senator?"

Trump's effort to make the race about Jones's politics — and to blunt the force of the allegations against the GOP candidate — could help Republican voters focus on substance in the run-up to the Dec. 12 election.

"What he said showed that he is taking a very keen interest in the state," said Noah Wahl, chairman of the Limestone County Republican Party in Alabama. "He definitely feels Roy Moore will be the best candidate to get his agenda."

And, Wahl added, Trump shored up his own base by standing with a candidate whom many Republicans in the state view as a good guy who has been unfairly maligned.

"I do think this will help the way people see him," Wahl said, "that he's coming out and supporting what a lot of Alabamians feel is true."