WASHINGTON — For more than two weeks he held back. Against all his instincts, President Trump for the most part resisted directly attacking the woman whose sexual assault allegation has jeopardized his Supreme Court nomination. The accuser was to be treated with kid gloves, like “a Fabergé egg,” as one adviser put it.

But Mr. Trump could resist only so long and told aides it was time to turn up the heat. So when he revved up a political rally this week by mocking Christine Blasey Ford, he indulged his desire to fight back and galvanized his conservative base even at the risk of alienating the very moderate Republicans he needs to confirm Judge Brett M. Kavanaugh to the Supreme Court.

The president’s scathing and derisive impression of Dr. Blasey, who has accused Judge Kavanaugh of sexually assaulting her when they were teenagers, came at the same time his Republican allies stepped up their efforts to challenge her veracity. Seizing on a sworn statement from a former boyfriend, Republicans suggested that she had not been fully truthful in her testimony before the Senate Judiciary Committee last week.

The gloves-off approach could further complicate Mr. Trump’s efforts to confirm Judge Kavanaugh to the Supreme Court by winning over three undecided Republican senators who have insisted that Dr. Blasey’s allegation be taken seriously, Susan Collins of Maine, Jeff Flake of Arizona and Lisa Murkowski of Alaska. The Senate will begin voting on Judge Kavanaugh on Friday and was expected to hold a final vote over the weekend.