As acting attorney general Sally Yates struggled to figure out how or whether to defend President Trump’s immigration order last weekend — while protests erupted at airports nationwide, immigrants were denied entry to the United States and civil rights lawyers rushed to court — two events helped crystallize her decision.

The first was a television appearance by Trump on the Christian Broadcasting Network. In an interview, he said that Christians in the Middle East who were persecuted should be given priority to move to the United States because they had been “horribly treated.”

The second was late Saturday night when former New York mayor Rudolph W. Giuliani appeared on Fox News. Giuliani said Trump wanted a “Muslim ban” and asked him to pull together a commission to show him “the right way to do it legally.”

“Those two things put the order in a very different light,” said a senior Justice Department official familiar with her decision. “Trump’s executive order appeared to be designed to make distinctions among different classes of people based on their religion.”

Next, Yates had to decide what to do. She had three options, according to the official, who like others spoke on the condition of anonymity to discuss private deliberations. She could have done nothing and instructed her attorneys to defend a law that she was not convinced was legal. She could have resigned, but those close to her say she believed she would have just been passing the responsibility to defend a potentially unlawful order to a successor. Or she could do what she ultimately chose — write a letter to Justice Department lawyers telling them to stop defending the order.

Jonathan Turley, a constitutional-law scholar at the George Washington University Law School, called Yates’s letter to the department “a mistake” and said that President Barack Obama’s Justice Department argued last year “that a federal court should not second-guess a president on immigration decisions” and “defended the president’s power to act unilaterally.”

Turley also said Yates’s firing could not be compared to the “Saturday Night Massacre” when President Richard M. Nixon dismissed independent special prosecutor Archibald Cox, prompting the resignations of the attorney general and deputy attorney general.

Yates’s firing “is less a massacre than a suicide,” Turley said.

Jack Goldsmith, a professor at Harvard Law School and a former assistant attorney general who headed the Office of Legal Counsel under President George W. Bush, said that Yates should have resigned if she could not defend the president’s order. He wrote on the blog Lawfare that the reasons Yates gave in her memo for not defending the order were “extraordinarily weak” and pointed out that she did not say she had concluded that the order was “unlawful” or that defending it in court would be “unreasonable.”

But a number of former senior Justice Department officials praised Yates for what they characterized as a courageous and principled stand.

“She could have resigned,” said Donald B. Verrilli Jr., who was solicitor general under Obama. “But my sense is that Sally thought there was something more at stake than just her own integrity. It was the integrity of the Department of Justice. We probably would have been a lot better off as a country if the attorney general in the 1940s had said, ‘I’m not going to allow the department to defend the internment of the Japanese.’ I think Sally thought this was a comparable situation. And I think she was right to think that. “

Former Colorado U.S. attorney John Walsh, head of the national Attorney General Advisory Committee, called Yates “one of the most principled people” he had ever worked with.

“I’m 100 percent certain she took what she believed was the only principled position she could take,” Walsh said.

Yates, 56, a longtime prosecutor from Atlanta and deputy attorney general under Obama, was taken by surprise when Trump issued his order Friday.

She had been asked to remain as acting attorney general after Loretta E. Lynch left at the end of the Obama administration.Yates and other officials from the administration had been working with lawyers from Trump’s “landing team” to help with their transition when the next attorney general, most likely Sen. Jeff Sessions (R-Ala.), came on board. They had all agreed to press pause, as one official put it, on taking any high-profile actions until Trump’s full team was in place.

“Sally wasn’t looking for a fight,” the official said.

But on Friday, Yates heard a media report that Trump had signed an executive order temporarily barring entry into the United States for citizens of seven Muslim-majority countries and refugees from around the world.

No one from the White House had consulted with Yates or any other senior leaders in the Justice Department. Yates had to decide whether her lawyers could defend Trump’s action in court. She did not even have a copy of the order, and her aides had to go online to find it.

“It was chaos,” said a senior Justice Department official.

The Justice Department’s Office of Legal Counsel had been asked by the White House to review Trump’s executive order. The OLC decided the order was lawful and properly drafted — a point that White House spokesman Sean Spicer made at his Tuesday briefing.

“At the end of the day, if the acting attorney general has an office under [her] jurisdiction that says that something is legal and compliant, and then she gets out there and says, ‘I’m not going to enforce it,’ that doesn’t sound like an attorney general that is upholding the duty that she swore to uphold,” Spicer said.

In her Monday memo, Yates said her role was broader than that of the OLC. She wrote that an OLC review does “not address whether any policy choice embodied in an Executive Order is wise or just,” nor does it “take account of statements made by an administration or its surrogates close in time to the issuance of an Executive Order that may bear on the order’s purpose.”