The hearing came as Trump seeks to bounce back from a series of stinging judicial defeats over his controversial effort to bar travelers from half a dozen mainly Muslim countries.
The question of intention is key since the US Constitution forbids religious discrimination. Trump’s detractors say it is beyond doubt that Muslims were the ban’s intended target, but the administration says it is motivated strictly by national security concerns, an area where US presidents have wide powers.
Trump "never intended for that to discriminate on the basis of any particular religion," Jeffrey Wall, the US acting solicitor general, told judges of the Fourth US Circuit Court of Appeals in Richmond during an intensely argued afternoon hearing.
"He made clear he was not talking about Muslims all over the world," said Wall. "That’s why it’s not a Muslim ban."
But a lawyer for the American Civil Liberties Union, Omar Jadwat, whose side is supported by several Democratic-led states, argued that Trump the candidate made clear he wanted to ban all Muslims for a time while studying enhanced immigration vetting.
A lower judge’s ruling dealt Trump a blow by freezing his second attempt to close US borders to citizens of Iran, Libya, Somalia, Sudan, Syria and Yemen for 90 days.
Given the public importance of the case, the full appeals court in Richmond heard the arguments -- bypassing the usual initial three-judge panel -- for the first time in a quarter-century.
Thirteen of the court’s 15 active judges took part. Two recused themselves over potential conflicts of interest, including the conservative J. Harvie Wilkinson, Wall’s father-in-law.
The court, once considered the most conservative appeals court in the country, now has nine judges named by Democratic presidents including Barack Obama, according to Carl Tobias of the University of Richmond School of Law.
The judges aggressively questioned both Wall and Jadwat, making it unclear which way they might be leaning.
They pressed Wall over whether Trump had acted in "bad faith", disguising an order targeting Muslims as one intended to prevent terrorism.
They said Trump’s comment, while signing his second order, that "you know what I mean" by the order was a "wink and a nod" to let supporters know he was really aiming at Muslims.
Judge Barbara Keenan suggested that Trump’s country-based order was bound to be sweeping and indiscriminate. "You’re talking about 82 million people aren’t you? It seems to me there has to be some linkage to show that there is a detrimental interest to the United States posed by 82 million people."
The judges also pressed Jadwat over whether an identical order issued by a president who had not made remarks against Muslims might be acceptable – and whether a president should not be granted some deference on security matters.
The federal court judge in Maryland issued a nationwide block on the ban’s core provision concerning travel from the short list of countries, saying the order raised the prospect of religious bias against Muslims.
That decision came just after a broader one issued in Hawaii that halted both the travel ban and a 120-day suspension of the US refugee admissions programme.
The White House is fighting that ruling in the Ninth US Circuit Court of Appeals, based in San Francisco.
The scope of Trump’s revamped ban, signed in early March, was reduced from his original January effort, which blocked travelers from seven-majority Muslim countries, including Iraq, as well as all refugees.
The first decree -- which prompted mass protests and sowed chaos at US airports -- was blocked on grounds it violated the ban on religious discrimination, a ruling upheld on appeal.
The modified version removed Iraq from the ban, but ran into the same objections.
A ruling is expected to take anywhere from one to six months.