Mr. Sessions delivered his resignation letter to the White House at the request of the president, who tapped Matthew G. Whitaker, Mr. Sessions’s chief of staff, as acting attorney general, raising questions about the future of the inquiry led by the special counsel, Robert S. Mueller III.
Mr. Whitaker, a former college football tight end and United States attorney in Iowa, and a onetime Senate candidate in that state, has previously questioned the scope of the investigation. In a column for CNN last year, he wrote that Mr. Mueller would be going too far if he examined the Trump family’s finances. “This would raise serious concerns that the special counsel’s investigation was a mere witch hunt,” Mr. Whitaker wrote, echoing the president’s derisive description of the investigation. Mr. Mueller has subpoenaed the Trump Organization for documents related to Russia.
Until now, Rod J. Rosenstein, the deputy attorney general, oversaw the investigation because Mr. Sessions recused himself in March 2017, citing his active role in Mr. Trump’s 2016 presidential campaign.
Democrats quickly demanded on Wednesday that Mr. Whitaker also remove himself from taking charge of the inquiry, citing potential conflicts of interest, including his criticisms of the Mueller investigation, as well as his connections to a witness in that investigation, Sam Clovis, a former Trump campaign aide. In 2014, Mr. Whitaker was the chairman of Mr. Clovis’s unsuccessful campaign to become Iowa state treasurer.
“Given his previous comments advocating defunding and imposing limitations on the Mueller investigation, Mr. Whitaker should recuse himself from its oversight for the duration of his time as acting attorney general,” Senator Chuck Schumer of New York, the Democratic leader, said in a statement.
[Read our profile from September of the acting attorney general, Matthew Whitaker.]
Mr. Whitaker had no immediate plans to publicly comment about Mr. Mueller or to take actions regarding the Russia inquiry, an administration official said.
“I am committed to leading a fair department with the highest ethical standards that upholds the rule of law and seeks justice for all Americans,” Mr. Whitaker said on Wednesday in a statement in which he also called Mr. Sessions “a man of integrity.”
But as acting attorney general, Mr. Whitaker would be in a position to impede or undermine the investigation or to block Mr. Mueller from delivering a final report on whether Mr. Trump’s campaign advisers conspired with Russia to influence the 2016 campaign, and whether the president tried to cover it up.
Any such step could set off a dramatic clash with the new Democratic majority in the House. Representative Jerrold Nadler, Democrat of New York, who will become the chairman of the House Judiciary Committee, was one of several Democrats to promise investigations once the party takes control in January.
Representative Adam B. Schiff, Democrat of California, who could become the new chairman of the House Intelligence Committee, said that any interference with the Mueller investigation “would cause a constitutional crisis and undermine the rule of law.”
But Republicans in Congress appeared less concerned by the president’s move. Senator Lindsey Graham, Republican of South Carolina, who said in 2017 that there would be “holy hell to pay” if Mr. Trump fired his attorney general, offered no criticism of the president on Wednesday.
“I look forward to working with President Trump to find a confirmable, worthy successor so that we can start a new chapter at the Department of Justice,” Mr. Graham said. He had in recent months begun to ease off his stance of last year, saying in August that it had become clear that Mr. Sessions had lost the president’s confidence.
The firing of Mr. Sessions came a day after midterm elections that handed control of the House to Democrats, dealing a major blow to Mr. Trump for the final two years of his term. Republicans preserved their hold on the Senate and increased their majority slightly, making it likelier that Mr. Trump would be able to confirm a replacement.
But House Democrats have made clear that they plan to use the subpoena power that will come with their majority to reopen the lower chamber’s own investigation into the Russia matter.
The abrupt ouster of Mr. Sessions resembled in some ways the decision by President George W. Bush to oust Defense Secretary Donald H. Rumsfeld in 2006 the day after a similar electoral defeat in midterm elections. In that case, Mr. Bush was attempting to mollify his critics. Mr. Trump’s decision to fire Mr. Sessions appeared likel to inflame his adversaries on Capitol Hill.
John F. Kelly, the White House chief of staff, called Mr. Sessions before the president’s postelection news conference on Wednesday to tell the attorney general that Mr. Trump wanted him to step down, the administration official said. Mr. Trump, who did not speak with Mr. Sessions himself, then ducked questions about Mr. Sessions’s fate at the news conference.
Mr. Sessions then had his letter, which was undated, delivered to the White House. “Dear Mr. President, at your request I am submitting my resignation,” he wrote. He added, “Most importantly, in my time as attorney general we have restored and upheld the rule of law,” and thanked the president.
Mr. Trump announced the resignation and Mr. Whitaker’s assignment on Twitter. “We thank Attorney General Jeff Sessions for his service, and wish him well!” he wrote. “A permanent replacement will be nominated at a later date.”
Though Mr. Trump has said for months that he wished to replace Mr. Sessions, lawmakers and administration officials believed that firing the attorney general before the midterm elections would have had negative consequences for Republicans in tight races. So it came as little surprise when Mr. Sessions was asked to resign the day after the midterms were over.
The president’s decision ended a partnership that soured almost from the start of the administration and degenerated into one of the most acrimonious public standoffs between a commander in chief and a senior cabinet member in modern American history.
Only weeks after he was confirmed as the United States’ top law enforcement officer, Mr. Sessions recused himself from overseeing the Justice Department investigation in March 2017, after revelations that he had failed to report encounters with Ambassador Sergey I. Kislyak of Russia during the 2016 campaign.
At the time, Mr. Sessions said there was nothing nefarious about those meetings, though he acknowledged that he “should have slowed down” and been more thoughtful in denying any contacts with Russian officials during his Senate confirmation process. His recusal was one of his first public acts as attorney general.
Mr. Trump never forgave him. At various points, he called Mr. Sessions “beleaguered,” “VERY weak” and “DISGRACEFUL.” In private, he referred to him derisively as “Mr. Magoo,” after the befuddled cartoon character.
In an interview with The New York Times in July of 2017, Mr. Trump first publicly revealed his anger with Mr. Sessions, kicking off 16 months of public fury toward his attorney general by saying he would not have hired Mr. Sessions had he known he would hand off oversight of the Russia inquiry.
“How do you take a job and then recuse yourself?” Mr. Trump said in the Oval Office interview. “If he would have recused himself before the job, I would have said, ‘Thanks, Jeff, but I can’t, you know, I’m not going to take you.’ It’s extremely unfair, and that’s a mild word, to the president.”
Mr. Trump also publicly badgered Mr. Sessions to open investigations into his defeated rival, Hillary Clinton, and other Democrats. Critics from both parties said the president was shredding the traditional independence of the law enforcement agencies in seeking what appeared to be politically motivated prosecutions.
For the most part, Mr. Sessions made no public retort. But after the president chided him in February for leaving an inquiry into the F.B.I.’s handling of the Russia investigation to an inspector general rather than conducting his own review, Mr. Sessions pushed back. “As long as I am the attorney general,” he said, “I will continue to discharge my duties with integrity and honor.”
When Mr. Trump said in August that Mr. Sessions “never took control of the Justice Department,” Mr. Sessions fired back, saying in a rare public rebuke that “the Department of Justice will not be improperly influenced by political considerations.”
Mr. Sessions tried to quit at least twice. In June 2017, shortly after his recusal, Mr. Trump berated Mr. Sessions during a private meeting in the Oval Office and accused him of “disloyalty.” Mr. Sessions grew emotional and agreed to resign. Reince Priebus, then the White House chief of staff, later said he ran out of the building to find the attorney general in the parking lot and stop him from leaving.
The deputy attorney general, now Mr. Rosenstein, would normally be in line to become the acting attorney general, but Mr. Trump has complained publicly about Mr. Rosenstein, too.
Installing Mr. Whitaker could clear the way for Mr. Trump to force out Mr. Mueller. To dismiss a special counsel, the president has to order the attorney general or, in the case of a recusal, the deputy attorney general, to carry it out. Mr. Rosenstein has said that he sees no justification to dismiss Mr. Mueller. Mr. Trump fired James B. Comey, the F.B.I. director originally overseeing the investigation.
During his new conference on Wednesday, Mr. Trump again insisted that he had the right to order an end to the investigation. “I could’ve ended it anytime I wanted,” he said. “I didn’t. There was no collusion. There was no anything.” But he did not rule it out. “It should end because it’s very bad for our country,” he said.
Mr. Whitaker’s ascendance to the top of the Justice Department shows how much loyalty means to Mr. Trump. The president has long regarded Mr. Whitaker as his eyes and ears inside a department that he considers an enemy institution.
Mr. Whitaker has been a frequent White House visitor and served as what one White House aide called a “balm” on the relationship between the president and the Justice Department.
In pushing out his attorney general, the president cast aside one of his earliest and strongest supporters.
In February 2016, Mr. Sessions became the first sitting senator to endorse Mr. Trump’s presidential campaign, and in the months leading up to the election, he became one of the candidate’s closest national security advisers and a key architect of the president’s hard-line immigration agenda.
As attorney general, Mr. Sessions has been instrumental in putting that agenda into practice, leading the assault on protections for young immigrants, ordering a “zero tolerance” crackdown on migrant families at the border, and helping to orchestrate changes aimed at severely reducing legal and illegal immigration.
Working with Stephen Miller, the president’s top domestic policy adviser, Mr. Sessions helped shape the president’s dark immigration message during the midterm elections, pushing for new efforts to separate families at the border, elimination of birthright citizenship, and more aggressive efforts to counter a caravan of migrants heading toward the United States from Central America.
He also fought for tougher sentencing for criminals, challenged so-called sanctuary cities and pursued the MS-13 gang.
But despite arguably being the most effective of Mr. Trump’s cabinet members on issues that the president deeply cared about, Mr. Sessions never recovered from Mr. Trump’s anger over his recusal in the Russia investigation.
Mr. Sessions, 71, got his start in politics as a United States attorney in Alabama, but his nomination for a federal judgeship was blocked by the Senate amid charges of racial insensitivity. He mounted a comeback by winning election as the state attorney general and then, in 1996, to the Senate.