The news that Attorney General Jeff Sessions had resigned Wednesday at President Trump’s request unnerved congressional Democrats, who immediately called for Sessions’s successor to recuse himself from oversight of the Russia investigation being led by special counsel Robert S. Mueller III.

Republicans, meanwhile, largely avoided any mention of the Mueller probe in their statements on Sessions’s departure, with several saying they were looking forward to working with Trump to find a long-term successor to the attorney general. Sessions will be succeeded on a temporary basis by his chief of staff, Matthew G. Whitaker.

Sen. Lamar Alexander (R-Tenn.) issued the closest thing to a warning from the Republican side, saying that the Senate will not confirm a successor to Sessions who would stop the Russia investigation.

Trump’s announcement came just hours after Trump threatened at a news conference to retaliate with a “warlike posture” against Democrats should they try to investigate him in the wake of their House victory on Tuesday. It also came after Republicans bolstered their ranks in the Senate with several new members who are ardent supporters of the president.

Some Democrats, such as Senate Minority Leader Charles E. Schumer (D-N.Y.), warned that any move by Trump to limit the Mueller probe would trigger a “constitutional crisis.”

“Our paramount view is that any attorney general, whether this one or another one, should not be able to interfere with the Mueller investigation in any way,” Schumer said at a Capitol Hill news conference.

The New York Democrat was caught off guard by Sessions’s resignation, learning of the news when an aide passed him a note at the start of his post-election news conference. He later said in a tweet that Whitaker should recuse himself given his previous comments about the probe.

During the 2016 presidential campaign, Whitaker wrote an op-ed for USA Today saying that, contrary to suggestions by then-FBI Director James B. Comey, a reasonable prosecutor would have opted to prosecute Hillary Clinton for violations of email protocol. Despite publicly offering his views on this matter and on Mueller’s activities, ethics experts suggest that he would not be required to recuse himself from Mueller-related decisions.

“There’s no legal conflict,” said ethics expert Stephen Gillers, a professor at New York University School of Law. “If he were a judge, the public comment could require recusal because it would create a question about his impartiality in ruling. But as acting AG, he’s a policymaker and is expected to have a policy position on how DOJ should deploy its resources and define the scope of Mueller’s work, just as Rosenstein has been doing.”

The GOP padded its slim 51-to-49 Senate majority on Tuesday, flipping Democratic-held seats in Missouri, Indiana and North Dakota, and three outstanding races are leaning toward Republicans. Asked whether the loss of Democratic seats makes it more difficult for the party to block an attorney general nominee it deems inappropriate, Schumer said the rules of the upper chamber already only require a simple majority, so it made no difference.

House Minority Leader Nancy Pelosi (D-Calif.) said in a tweet that it was “impossible to read Attorney General Sessions’ firing as anything other than another blatant attempt by @realDonaldTrump to undermine & end Special Counsel Mueller’s investigation.’’

Rep. Jerrold Nadler (D-N.Y.), the incoming chairman of the House Judiciary Committee, said in a tweet that the country needs answers as to the reasons behind Sessions’s removal.

“Why is the President making this change and who has authority over Special Counsel Mueller’s investigation? We will be holding people accountable,” Nadler asked.

Other Democrats focused specifically on Whitaker, with Sen. Richard Blumenthal (D-Conn.), a member of the Senate Judiciary Committee, calling it “a break the glass moment.”

Blumenthal was among several Democrats and a handful of Republicans who pushed for Congress to pass a bill protect a special counsel from indiscriminate firing, by giving that counsel the ability to swiftly appeal that decision in the courts. But momentum around the bill flagged over the several months since it was introduced — and even the Republican co-sponsors of the legislation declared last month that there was no need to pass the measure to constrain the president.

“Replacing the Attorney General with a non-Senate-confirmed political staffer is highly irregular and unacceptable,” Blumenthal said in a statement, urging Republicans to join Democrats in demanding that Whitaker recuse himself from overseeing the Mueller probe. He also said he would introduce new legislation to “ensure that Congress and the American people see the results of Special Counsel Mueller’s work.”

Democrats had closed ranks around Sessions because of one thing: his voluntary recusal from all matters pertaining to the 2016 campaigns, and, by extension, Mueller’s probe. That meant oversight of the probe fell to Deputy Attorney General Rod J. Rosenstein.

Any replacement for Sessions, however, would resume authority over the probe, and Whitaker has criticized its scope in the past. Democrats fear that even if he does not shut it down, he could hamstring the special counsel as Mueller seeks to advance his investigation.

Among Republicans, only a few raised the issue of the probe, with Alexander suggesting that the Senate would move to block any nominee who seeks to end it.

“The one thing this does make certain is that the Mueller investigation into Russian meddling in elections will continue to its end, as it should, because no new Attorney General can be confirmed who will stop that investigation,” Alexander said in a tweet.

Sen. Susan Collins (R-Maine) and Sen.-elect Mitt Romney (R-Utah) also said on Twitter that it is “imperative” that the Trump administration allow Mueller to finish his investigation without interference.

Many Republicans had previously voiced opposition to the idea of Trump removing Sessions and were angered by the president’s persistent public attacks on one of their former Senate colleagues. But on Wednesday, they were noticeably less critical.

Last year, Sen. Lindsey O. Graham (R-S.C.) had declared himself “100 percent” behind Sessions and warned that “there will be holy hell to pay” if Trump fired his attorney general.

On Wednesday, Graham, who has transformed into one of Trump’s strongest defenders in recent months, gave his blessing to the president’s move.

Graham’s name has been floated around the halls of Congress as a potential replacement for Sessions — but he hinted strongly in his comments that he planned to stay in the Senate and not put his hand up for the attorney general job.

“I look forward to working with President @realDonaldTrump to find a confirmable, worthy successor so that we can start a new chapter at the Department of Justice and deal with both the opportunities and challenges our nation faces,” Graham said in a tweet.

Senate Majority Leader Mitch McConnell (R-Ky.) struck a similar note, thanking Sessions for his service and saying that he looks “forward to working with him in any future endeavors.”

“Throughout his career, as a prosecutor, a senator and as attorney general, he remained steadfast in his commitment to the rule of law and his love of our great nation,” McConnell said, making no mention of the Russia investigation.

Senate Judiciary Committee Chairman Charles E. Grassley (R-Iowa) once warned Trump that if he fired Sessions, there was “no way” he would hold a hearing to approve his replacement.

But Grassley softened on that conviction this year, saying that he would be “willing to work with the president on any nominee he sends up here to the Senate,” Grassley spokesman George Hartmann said. On Wednesday, Grassley thanked Sessions in a tweet and made no mention of the search for his successor.

Sen. Tim Scott (R-S.C.) expressed the hope that Trump selects a candidate who backs efforts to overhaul the criminal justice system. Sessions has been resistant to the effort.

“I want to thank Jeff Sessions for his service to our nation,” Scott said. “I am hopeful that President Trump will take this opportunity to nominate a replacement that is invested in criminal justice reform.”

Among those criticizing Trump’s move on Wednesday was former attorney general Eric Holder, who drew a direct line between Sessions’s removal and the Mueller probe.

“Anyone who attempts to interfere with or obstruct the Mueller inquiry must be held accountable,” Holder said in a tweet. “This is a red line. We are a nation of laws and norms not subject to the self interested actions of one man.”

Tom Hamburger, Gabriel Pogrund, Paul Kane and Mike DeBonis contributed to this report.