WASHINGTON/NEW YORK (Reuters) - Federal appeals court judges on Friday asked about President Donald Trump’s sharing of anti-Muslim videos on his Twitter account, as they grilled a U.S. government lawyer about the legality of the president’s latest travel ban.

FILE PHOTO: International passengers arrive at Washington Dulles International Airport after the U.S. Supreme Court granted parts of the Trump administration's emergency request to put its travel ban into effect later in the week pending further judicial review, in Dulles, Virginia, U.S., June 26, 2017. REUTERS/James Lawler Duggan/Files

Judge Pamela Harris asked government lawyer Hashim Mooppan about Trump’s Nov. 29 online sharing of three anti-Muslim videos posted on Twitter by a far-right British party leader. Lawyers say that and earlier statements by Trump prove the policy is aimed at blocking the entry of Muslims, rather than the president’s stated goal of preserving national security.

“Even with deference, construing them in the light most favorable to the president, it’s a little tricky to find the national security rationale in those” Twitter posts, Harris said at the 4th U.S. Circuit Court of Appeals hearing in Richmond, Virginia, monitored by Reuters over audio feed.

This week, the U.S. Supreme Court allowed the ban to take effect while litigation over its ultimate validity unfolds. Certain categories of people from Chad, Iran, Libya, Somalia, Syria and Yemen are barred from entering the United States, as well as people from North Korea and some government officials from Venezuela. The Republican president has said the ban is needed to protect the United States from terrorism.

However, Judge James A. Wynn Jr. said Trump “tweets the very thing” that his opponents claim is behind the ban. “What do we do with that?”

On Wednesday, the 9th U.S. Circuit Court of Appeals held a hearing over the ban, in a separate case brought by the state of Hawaii.

A lawyer from the American Civil Liberties Union argued against the ban on behalf of several refugee groups, civil rights groups and individual American Muslims who say they are harmed by the ban.

Mooppan argued on behalf of the government that the latest travel ban should be considered on its own merits, and separately from statements Trump has made on social media or elsewhere that could be construed to be anti-Muslim. He noted that the latest iteration of the ban came after a review by government agencies.

“I need you to explain to me how a review process by subordinate executive branch officials is an independent act that can cure the taint from presidential statements,” Harris, an Obama appointee, said to Mooppan.

Judge Barbara Milano Keenan, also an Obama appointee, asked why nationality was more relevant than other factors such as gender in considering the potential for terrorist acts.

“Could he ban the entry of all men until evidence showed further that men are not the ordinary and customary perpetrators of terrorist activity?” Keenan asked. “If 99 percent of terrorist acts are committed by men, aren’t we really protecting this country if we just keep out the men?”

Mooppan pointed to previous bans on the entry of Iranians by Democratic President Jimmy Carter and Cubans by Republican President Ronald Reagan as examples of presidents who barred people based on nationality.

ACLU attorney Cecillia Wang faced tough questioning from Judge Paul Niemeyer, who asked when it would be justified for courts to question the national security determinations of the president.

“All foreign policy is a black box and it should be,” said Niemeyer, a George H.W. Bush appointee.

Trump issued his first travel ban in January. The order, which targeted several Muslim-majority countries, caused chaos at airports and was blocked by courts. He revised it in March, and that ban expired in September after a long court fight. It was replaced with the current version.

The U.S. Supreme Court is expected to ultimately decide the issue in the coming months.