WASHINGTON – For nearly four years, congressional Republicans have ducked and dodged an unending cascade of offensive statements and norm-shattering behavior from President Donald Trump, ignoring his caustic and scattershot Twitter feed and penchant for flouting party orthodoxy, and standing quietly by as he abandoned military allies, attacked American institutions and stirred up racist and nativist fears.

But now, facing grim polling numbers and a flood of Democratic money and enthusiasm that has imperiled their majority in the Senate, Republicans on Capitol Hill are beginning to publicly distance themselves from the president. The shift, less than three weeks before the election, indicates that many Republicans have concluded that Trump is heading for a loss in November. And they are grasping to save themselves and rushing to re-establish their reputations for a coming struggle for their party's identity.

Sen. Ben Sasse of Nebraska unleashed on Trump in a telephone town hall event with constituents on Wednesday, eviscerating the president's response to the coronavirus pandemic and accusing him of "flirting" with dictators and white supremacists and alienating voters so broadly that he might cause a "Republican bloodbath" in the Senate. He was echoing a phrase from Sen. Ted Cruz of Texas, who warned of a "Republican bloodbath of Watergate proportions." Sen. Lindsey Graham of South Carolina, one of the president's most vocal allies, predicted the president could very well lose the White House.

Even the normally taciturn Sen. Mitch McConnell, R-Ky., the majority leader, has been more outspoken than usual in recent days about his differences with the president, rejecting his calls to "go big" on a stimulus bill. That was a reflection of the fact that Senate Republicans — who have rarely broken with the president on any major legislative initiative in four years — are unwilling to vote for the kind of multitrillion-dollar federal aid plan that Trump has suddenly decided would be in his interest to embrace.

"Voters are set to drive the ultimate wedge between Senate Republicans and Trump," said Alex Conant, a former aide to Sen. Marco Rubio and a former White House spokesman. "It's a lot easier to get along when you're winning elections and gaining power. But when you're on the precipice of what could be a historic loss, there is less eagerness to just get along."

Republicans could very well hang on to both the White House and the Senate, and Trump still has a firm grip on the party base, which may be why even some of those known for being most critical of him, like Sasse and Sen. Mitt Romney of Utah, declined to be interviewed about their concerns.

But their recent behaviors have offered an answer to the long-pondered question of if there would ever be a point when Republicans might repudiate a president who so frequently said and did things that undermined their principles and message. The answer appears to be the moment they feared he would threaten their political survival.

If some Senate Republicans have written off Trump's chances of victory, the feeling may be mutual. On Friday, the president issued his latest Twitter attack on Sen. Susan Collins of Maine, one of the most endangered Republican incumbents.

"There is a nasty rumor out there that @SenatorCollins of Maine will not be supporting our great United States Supreme Court Nominee," Trump tweeted. "Well, she didn't support Healthcare or my opening up 5000 square miles of Ocean to Maine, so why should this be any different. Not worth the work!"

The grim political environment has set off a scramble, especially among Republicans with political aspirations stretching beyond Trump's presidency, to be on the front lines of any party reset.

"As it becomes evident that he is a mere political mortal like everyone else, you're really starting to see the jockeying taking place for what the future of the Republican Party is," said Carlos Curbelo, a former Republican congressman from Florida who did not support Trump in 2016. "What we heard from Senator Sasse yesterday was the beginning of that process."

On the campaign trail, Republicans are privately livid with the president for dragging down their Senate candidates, sending his struggles rippling across states that are traditional Republican strongholds.

"His weakness in dealing with coronavirus has put a lot more seats in play than we ever could have imagined a year ago," said Whit Ayres, a Republican pollster and consultant. "We always knew that there were going to be a number of close Senate races, and we were probably swimming against the tide in places like Arizona, Colorado and Maine. But when you see states that are effectively tied, like Georgia and North Carolina and South Carolina, that tells you something has happened in the broader environment."