RICHMOND, Va. — Federal appeals court judges in Virginia peppered a government lawyer Friday with questions about President Donald Trump’s latest travel ban and whether the president has the authority to ban 150 million foreign nationals — mostly Muslims — from the United States.

A full panel of 13 judges from the 4th U.S. Circuit Court of Appeals heard arguments on the third version of Trump’s travel ban. It was the second federal appeals court to hear a challenge to the ban this week, following a hearing Wednesday before the San Francisco-based 9th Circuit.

The hearing came four days after the U.S. Supreme Court said it would allow the travel restrictions to go into full effect, at least until the two appeals courts ruled on separate lawsuits challenging the ban.

The 4th Circuit is being asked to reverse a decision by a Maryland judge whose injunction in October barred the administration from enforcing the ban against travellers from Chad, Iran, Libya, Somalia, Syria and Yemen who have bona fide relationships with people or organizations in the U.S.It also blocks travel by North Koreans along with some Venezuelan government officials and their families, although those parts of the restrictions are not being challenged.

Deputy Assistant Attorney General Hashim Mooppan told the judges that the latest travel restrictions were the product of a global, multiagency review that found the countries do not share enough security-related information with the United States. He insisted the latest travel ban is not anti-Muslim, but is necessary for national security.

“The proclamation says there’s inadequate information sharing from these eight countries or other risk factors that undermine visa vetting, and to deal with that problem — a particular aspect of the broader terrorism problem — they are imposing entry restrictions to those (countries) to improve those practices and protect this nation until they do so,” Mooppan said.

He said the president has broad executive authority to bar aliens he believes would be detrimental to the interests of the United States.

Cecillia Wang, a deputy legal director at the national American Civil Liberties Union, told the judges that the ban is a manifestation of Trump’s campaign promise to keep Muslims out of the United States. Wang cited various statements made by Trump and anti-Muslim videos he retweeted on Nov. 29, saying he has “doubled down” on his pledge.

“It’s clear on the record that the president has continued to make statements of hostility toward Muslims,” Wang said.

The judges differed on whether they should consider Trump’s statements and tweets. Judge Paul Niemeyer called Trump’s statements “background noise,” while Judge James Wynn asked if the court should “ignore reality” and just look at the legality of the travel ban.

The 4th Circuit cited Trump’s remarks on Muslim travellers while rejecting an earlier version of the travel ban in May, finding that it “drips with religious intolerance, animus and discrimination” toward Muslims.

Niemeyer suggested that the challenges to the administration’s travel restrictions are based largely on Trump’s statements and not on the ban itself.

“How about if another candidate won the presidential election and entered this proclamation? You wouldn’t even be here,” he said to Wang.

Wang said it “would be a different case” without the statements Trump has made about Muslims, but said the ban itself violates the U.S. Constitution because it discriminates against Muslims.

“The president was acting out of a purpose to disfavour Islam and he directed his lower-level officials to carry out his original purpose in the original way he meant to do that, which was by using nationality as a proxy to religion,” she said.

Several judges questioned Mooppan about the scope of the ban. Judge Albert Diaz said he was struggling with the administration’s stated goal that the ban will prompt unco-operative countries to improve their information-sharing processes on security issues.

“This is a wholesale ban of 150 million-plus nationals based on the hope and expectation that this will incentivize the nations to co-operate. The connection there to me is missing,” said Judge Albert Diaz.

Trump announced his initial travel ban on citizens of certain Muslim-majority nations in late January, bringing havoc and protests to airports around the country. A federal judge in Seattle soon blocked it, and courts since then have wrestled with the restrictions as the administration has rewritten them. The latest version blocks travellers from the listed countries to varying degrees, allowing for students from some of the countries while blocking other business travellers and tourists, and allowing for admissions on a case-by-case basis.

It is unclear when the appeals courts will rule, though both sides expect the U.S. Supreme Court will ultimately decide on the legality of the ban.