ATLANTA — As a young prosecutor in the late 1990s, Sally Q. Yates sat at a conference table with a former sheriff and began picking away at his story. With an F.B.I. agent watching, Ms. Yates soon had the lawman in knots about a deposition.

“I watched him as she broke him down, and he confessed that he had lied under oath,” the agent, Oliver G. Halle, now retired, recalled on Tuesday. “She can be very disarming, but underneath that disarming appearance is a woman who knows how to fight.”

As acting attorney general, Ms. Yates picked the fight of her life on Monday when she ordered the Justice Department not to defend President Trump’s executive order blocking refugees and restricting immigration to the United States. Ms. Yates became convinced, based on the president’s own statements, that he had intended to unlawfully single out Muslims, senior officials said.

“We have comments from the president about what this is supposed to do,” Ms. Yates said in one meeting on Monday, according to two people involved in the discussions. She later added, “The intent was clear from the face of it.”

Ms. Yates, 56, was swiftly fired. Before she even finished packing up her office, she had become a hero to many Democrats, the face of a simmering resistance inside the government to Mr. Trump’s administration.

Video

Richard Blumenthal, Democratic senator from Connecticut, said he saluted Sally Q. Yates’s legal principle and questioned whether the next attorney general would uphold the rule of law.CreditCreditZach Gibson/The New York Times

Her firing was a politically divisive turn in a career that had, until now, earned her bipartisan praise.

“She will be a hero of the American people, a hero of what’s right,” Senator Johnny Isakson, Republican of Georgia, said in 2015 at Ms. Yates’s confirmation hearing. “She’ll call them like she sees them, and she will be fair, and she will be just.”

While Ms. Yates was a reliably liberal voice in the Justice Department on issues of civil rights, criminal justice and sentencing, she worked her way up as a career prosecutor in Atlanta under political appointees from both parties. A native Georgian, she led prosecutions against some of the highest profile defendants in Atlanta, including former Mayor Bill Campbell, a Democrat who was accused of racketeering and tax fraud, and Eric Robert Rudolph, who set bombs at a park during the 1996 Olympic Games, a gay nightclub and two Southern abortion clinics.

She also took on the leaders of an Atlanta suburb who refused to allow construction of a mosque. The Justice Department sued, and the city reversed itself. “Religious freedom requires that local government decisions impacting the exercise of that freedom be free of discrimination,” Ms. Yates said at the time.

When Ms. Yates, who declined to comment on Tuesday, became deputy attorney general in 2015, she told colleagues that she had no intention of merely being a caretaker. “We’re going to run through the tape,” she often said.

In Washington, her outgoing personality made her a counterpoint to her more reserved boss, Attorney General Loretta E. Lynch. At times that made Ms. Yates the face of the Justice Department in ways that caused tension with Ms. Lynch’s staff. Ms. Yates was regarded as professionally ambitious, though she has told friends that she has no interest in running for political office.

Last year, Ms. Yates and Ms. Lynch earned the ire of Democrats — including many in the department — for not intervening to prohibit the F.B.I. director, James B. Comey, from sending a letter to Congress in the final days of the presidential campaign. The letter raised the prospect of new and potentially damaging evidence against Hillary Clinton related to an investigation that had been closed. Nothing came of the new evidence, and Mrs. Clinton’s team says the letter cost her the presidency. Her supporters argued that Justice Department leaders were too timid to stand up to Mr. Comey.

Mr. Trump’s executive order prompted a new challenge for Ms. Yates, who was serving until the Senate confirmed a new attorney general. The Justice Department’s Office of Legal Counsel had reviewed and signed off on the order, but Ms. Yates believed that the department had to also consider the president’s intent, which she said appeared aimed at singling out people based on religion.

Mr. Trump had promised to do as much. His campaign website still calls for a “total and complete shutdown of Muslims entering the United States until our country’s representatives can figure out what is going on.” After the decision was announced, one of his advisers, Rudolph W. Giuliani, the former mayor of New York, said in an interview that Mr. Trump had wanted a Muslim ban but needed “the right way to do it legally.” Mr. Trump then said in an interview with the Christian Broadcasting Network that Christian refugees would be given priority for entry visas to the United States.

In meetings on Monday, some in the department said it should defend the order, as it normally does. Others disagreed.

But others, like Jack Goldsmith, said she should have either defended the president’s order or resigned. George J. Terwilliger III, a former deputy attorney general who, like Ms. Yates, served briefly as acting attorney general, said that Ms. Yates had made herself and the Justice Department “look blatantly political.”

Video

At Sally Q. Yates’s 2015 confirmation hearing for deputy attorney general, a Republican senator questioned her willingness to oppose the president. That senator, Jeff Sessions of Alabama, is now President Trump’s pick for the new attorney general.CreditCreditCarolyn Kaster/Associated Press

Ms. Yates considered resigning, four current and former Justice Department officials said, but she concluded that doing so would only defer a difficult decision to a temporary successor.

That dilemma was foreshadowed two years ago in her confirmation hearing, when Senator Jeff Sessions, the Alabama Republican who is poised to become the next attorney general, questioned whether Ms. Yates had the independent streak needed to be the Justice Department’s second in command.

“If the views the president wants to execute are unlawful, should the attorney general or the deputy attorney general say no?” Mr. Sessions asked.

“I believe the attorney general or deputy attorney general has an obligation to follow the law and Constitution and give their independent legal advice to the president,” Ms. Yates replied.

Shortly after 9 p.m. on Monday, roughly three hours after she ordered department lawyers not to defend the president’s position, a White House courier arrived with a copy of her dismissal letter.

“Dear Deputy Attorney General Yates,” said the letter, which was signed by John DeStefano, an assistant to Mr. Trump. “I am informing you that the president has removed you from the office of Deputy Attorney General of the United States.”

A version of this article appears in print on , on Page A15 of the New York edition with the headline: Trump’s Talk on Muslims Led Acting Attorney General to Defy Immigration Order. Order Reprints | Today’s Paper | Subscribe