Accusing her of betrayal and insubordination, U.S. President Donald Trump on Monday fired Sally Yates, the acting attorney general of the United States and a Democratic appointee, after she publicly questioned the constitutionality of his controversial refugee and immigration ban and refused to defend it in court.

The dramatic public clash between the new president and the nation's top law enforcement officer laid bare the growing discord and dissent surrounding Trump's executive order, which temporarily halted the entire U.S. refugee program and banned all entries from seven Muslim-majority nations for 90 days.

The firing came hours after Yates directed Justice Department attorneys not to defend the executive order, saying she was not convinced it was lawful or consistent with the agency's obligation "to stand for what is right."

A person familiar with Yates' thinking says the former acting attorney general has told others she felt Trump's executive order appeared to favour Christians over Muslims and she was troubled by that.

The person says Yates knew her firing was a likely outcome if she refused to enforce the order, but did not want to resign and leave the problem unresolved for someone else.

The person was not authorized to discuss the situation by name and spoke only on condition of anonymity.

Yates … is weak on borders and very weak on illegal immigration. — White House statement

Trump soon followed up with a statement accusing Yates of having "betrayed" the Justice Department by refusing to enforce what he described as a "legal order designed to protect the citizens of the United States."

"Yates … is weak on borders and very weak on illegal immigration," the statement from the White House added.

Trump immediately named longtime federal prosecutor Dana Boente, the U.S. attorney for the eastern district of Virginia, as Yates's replacement. Boente was sworn in privately late Monday, the White House said.

Boente has ordered the Justice Department to "do our sworn duty" and defend Trump's executive order on immigration and refugees.

Boente said in a statement issued by the Justice Department that Trump's executive order is "both lawful on its face and properly drafted."

FILE - In this Jan. 26, 2012, file photo, Dana Boente, then-First Assistant U.S. Attorney for the Eastern District of Virginia leave federal court in Alexandria, Va. (Evan Vucci/Associated Press)

As well, the acting director of U.S. Immigrations and Custom Enforcement (ICE) was replaced on Monday. Daniel Ragsdale was succeeded by Thomas Homan, the Department of Homeland Security said.

An explanation for the change was not offered.

Yates's refusal to defend the executive order was largely symbolic given that Senator Jeff Sessions, Trump's pick for attorney general, will almost certainly defend the policy once he's sworn in.

Yates's abrupt decision reflected the growing conflict over the executive order, with administration officials moving Monday to distance themselves from the policy. As protests erupted at airports over the weekend and confusion disrupted travel around the globe, even some of Trump's top advisers and fellow Republicans made clear they were not involved in crafting the policy or consulted on its implementation.

Acting Attorney General Sally Yates directed Justice Department attorneys not to defend Trump's controversial executive order. (J. David Ake/Associated Press)

Yates questions legality

Yates had directed Justice Department attorneys not to defend Trump's controversial executive refugee and immigration ban in a letter Monday announcing her position.

"I am responsible for ensuring that the positions we take in court remain consistent with this institution's solemn obligation to always seek justice and stand for what is right," Yates wrote.

"At present, I am not convinced that the defence of the executive order is consistent with these responsibilities, nor am I convinced that the executive order is lawful."

Yates was appointed deputy attorney general in 2015 and was the No. 2 Justice Department official under Loretta Lynch.

At least three top national security officials — Defence Secretary Jim Mattis, Homeland Security Secretary John Kelly and Rex Tillerson, who is awaiting confirmation to lead the State Department — have told associates they were not aware of details of the directive until around the time Trump signed it.

Leading intelligence officials were also left largely in the dark, according to U.S. officials.

Tennessee Senator Bob Corker, the top Republican on the Senate Foreign Relations committee, said that despite White House assurances that congressional leaders were consulted, he learned about the order in the media.

Trump's order pauses the entire U.S. refugee program for four months, indefinitely bans all those from war-ravaged Syria and temporarily freezes immigration from Iraq, Syria, Iran, Sudan, Libya, Somalia and Yemen.

Federal judges in New York and several other states issued orders that temporarily block the government from deporting people with valid visas who arrived after Trump's travel ban took effect and found themselves in limbo.

Volunteer lawyers work in a dining area to assist travellers detained as part of Donald Trump's travel ban, in Terminal 4 at John F. Kennedy International Airport in Queens, New York. (Andrew Kelly/Reuters)

'Get with the program'

Trump said the order had been "approved" by Justice Department lawyers. However, the department has said the Office of Legal Counsel review was limited to whether the order was properly drafted, but did not address broader policy questions.

Other parts of Trump's administration also voiced dissent Monday. A large group of American diplomats circulated a memo voicing their opposition to the order.

White House spokesman Sean Spicer challenged those opposed to the measure to resign.

"They should either get with the program or they can go," Spicer said.

The blowback underscored Trump's tenuous relationship with his own national security advisers, many of whom he met for the first time during the transition.

Demonstrators yell slogans during protest against the travel ban imposed by U.S. President Donald Trump's executive order, at Los Angeles International Airport in Los Angeles, Calif., on Sunday. (Ted Soqui/Reuters)

Mattis, who stood next to Trump during Friday's signing ceremony, is said to be particularly incensed. A senior U.S. official said Mattis, along with Joint Chiefs Chairman Joseph Dunford, was aware of the general concept of Trump's order but not the details. Tillerson has told the president's political advisers that he was baffled over not being consulted on the substance of the order.

U.S. officials and others with knowledge of the cabinet's thinking insisted on anonymity in order to disclose the officials' private views.

Despite his public defence of the policy, the president has privately acknowledged flaws in the rollout, according to a person with knowledge of his thinking. But he's also blamed the media — his frequent target — for what he believes are reports exaggerating the dissent and the number of people actually affected.

After a chaotic weekend during which some U.S. legal permanent residents were detained at airports, some agencies were moving swiftly to try to clean up after the White House.

Homeland Security, the agency tasked with implementing much of the refugee ban, clarified that customs and border agents should allow legal residents to enter the country. The Pentagon was trying to exempt Iraqis who worked alongside the U.S. and coalition forces from the 90-day ban on entry from the predominantly Muslim countries.