Former New York City mayor Rudy Giuliani told Fox in an interview on Saturday that he helped draft President Donald Trump’s “extreme vetting” executive order after Trump called him and asked how to “do a Muslim ban legally.”

“When he first announced it, he said ‘Muslim ban,'” Giuliani, who served as the vice chairman of Trump’s transition team, told Fox. “He called me up. He said ‘put a commission together. Show me the right way to do it legally.'”

Giuliani then put a commission together with Judge Mike Mukasey, Congressman Mike McCaul, Rep. Pete King, and a “whole group of very expert lawyers on this,” he said.

“We focused on, instead of religion, on danger,” Giuliani continued. “The areas of the world that create danger for us. Which is a factual basis, not a religious basis. Perfectly legal, perfectly sensible. And that’s what the ban is based on.”

Experts have noted that the countries included in the ban — Iraq, Syria, Iran, Sudan, Libya, Somalia and Yemen — seem arbitrary, and do not include countries that have posed serious terror threats in the past such as Pakistan, Saudi Arabia, Egypt, and the United Arab Emirates.

The order cites the September 11, 2001 terror attacks three times as justification for the ban, but the 9/11 hijackers were from Egypt, Saudi Arabia, the United Arab Emirates, and Lebanon — none of which were included on the list of banned countries.

Trump insisted on Saturday that the order is “not a Muslim ban.”

“It’s not a Muslim ban,” Trump told reporters in the Oval Office at the White House. “It’s working out very nicely. You see it at the airports, you see it all over.”

Large protests erupted at airports across the country on Saturday as news emerged that people from the banned countries who had valid visas and green cards were being detained — and, in some cases, deported — by customs officials and border patrol agents.

Lawyers representing two Iraqi refugees who were detained at John F. Kennedy airport in New York filed legal challenges to Trump’s executive order, and a federal judge in Brooklyn issued an emergency ruling Saturday evening to prevent the continued deportation of travellers.

The ruling, a temporary emergency stay, now allows those who landed in the US and hold a valid visa to remain. Federal judges in Virginia, Massachusetts, and Washington also made emergency rulings on various aspects of the executive order.

Lawyers and civil rights organisations have argued that the ban violates the Establishment Clause of the First Amendment by “explicitly disapproving of one religion and implicitly preferring others.”

Because the ban does not explicitly mention “Islam” or “Muslims,” however, it may be shielded from legal challenges arguing that it violates the Constitution’s guarantees of religious freedom and due process.

Business Insider Emails & Alerts Site highlights each day to your inbox. Email Address Join

Follow Business Insider Australia on Facebook, Twitter, LinkedIn, and Instagram.