(Jenny Starrs/The Washington Post)

Acting attorney general Sally Quillian Yates, a longtime prosecutor from Atlanta, began her tenure as an Obama appointee two years ago by saying that pursuing justice was more important to her than bringing federal cases in court.

“We’re not the Department of Prosecutions or even the Department of Public Safety,” Yates said in May 2015, the week after she was confirmed as deputy attorney general, the second-highest-ranking position in the Justice Department. “We are the Department of Justice.”

On Monday afternoon, only days away from stepping down from her 27-year career in the Justice Department, Yates defied President Trump, ordering federal attorneys not to defend the controversial immigration order issued Friday.

Within hours, Trump fired her. In a news release, the White House said Yates had “betrayed the Department of Justice by refusing to enforce a legal order designed to protect the citizens of the United States.” Yates was replaced by Dana Boente, U.S. attorney for the Eastern District of Virginia, who told The Washington Post he would enforce the president’s directive until Trump nominee Sen. Jeff Sessions (R-Ala.) is confirmed.

Sally Quillian Yates, photographed at the Justice Department in 2015. (Evelyn Hockstein/For The Washington Post)

Yates, 56, struggled with her decision over the weekend, said an official who spoke on the condition of anonymity given the sensitivity of the situation. By Monday, though, she had concluded that she could not ask her federal attorneys to defend the order.

Yates could not be reached for comment.

She sent a memo to the civil division of the Justice Department and U.S. attorneys across the country saying she was not “convinced” the order was lawful, and “as long as I am the Acting Attorney General, the Department of Justice will not present arguments in defense of the Executive Order, unless and until I become convinced that it is appropriate to do so.”

Hours later, at about 9:15 p.m., Yates received a hand-delivered letter from the White House that the president was removing her from office.

“She did what she believes was the right thing to do and then she gets fired for it,” the official said. “This is not how she would have preferred to end her 27-year career. But she did what she had to do.”

Those who know Yates well said that her action was consistent with the independence and commitment to the rule of law they say she has exhibited throughout her career.

“For nearly three decades, Acting Attorney General Sally Yates has served Presidents of both parties, defending the Constitution and holding terrorists and other criminals accountable,” said former labor secretary Tom Perez, who was head of the civil rights division in the Obama administration.

“Acting Attorney General Yates’s record is simply beyond reproach,” said Perez, who is running to be chair of the Democratic National Committee.

But Trump’s senior policy adviser, Stephen Miller, blasted Yates on Fox News after the acting attorney general was fired.

“It can’t be stated strongly enough how reckless, irresponsible and improper the behavior was of the acting attorney general, Sally Yates, in refusing to defend the president’s order,” said Miller, who accused Yates of “refusing to defend the lawful power of the president.” He added that he had no doubt about the legality of the order.

For the past two years, Yates has been responsible for the day-to-day running of the 113,000-employee Justice Department. She was also responsible for overseeing the Justice Department’s work on the prior White House’s clemency initiative, in which the president granted commutations to thousands of nonviolent drug offenders who met certain criteria set out by the administration.

She also wrote a new policy two years ago that became known as “the Yates memo,” which made the prosecution of individual executives — not just the corporations that employ them — a top priority for federal prosecutors.

Last month, Yates was one of the Justice officials who announced that federal prosecutors indicted six executives at Volkswagen in connection with the company’s diesel emissions scandal; the company agreed to pay $4.3 billion in criminal and civil penalties.

Former Justice Department spokeswoman Emily Pierce said that Yates was known in the department for voicing her opinions when she thought the administration was going in the wrong direction. Pierce said Yates was particularly vocal during a debate over government access to encrypted communications during criminal investigations, when some officials wanted to make it harder for law enforcement to access the locked information.

“She advocated very strongly as a one-woman show for law enforcement and made the Obama administration pause on policies she thought would be harmful,” Pierce said.