Media playback is unsupported on your device Media caption President Trump's travel ban court battle explained

A US appeals court has posed tough questions at those challenging and defending President Donald Trump's controversial travel ban.

The order banned entry for all refugees and visitors from seven mainly Muslim nations, until it was halted last week.

The three-judge panel raised questions over the limits on the president's power and Mr Trump's evidence to link the seven countries to terrorism.

But it also asked whether the measure could be considered anti-Muslim.

A decision from the 9th US Circuit Court of Appeals, in San Francisco, is expected later this week. Whatever it decides, the case will probably end up in the Supreme Court.

What did the two sides argue at the appeals court?

There was an hour of oral arguments from both sides on Tuesday.

The Justice Department was first to make its case, urging the appeal judges to reinstate the banning order.

Lawyer August Flentje said Congress had authorised the president to control who can enter the country.

When asked to point to evidence that the seven countries affected - Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen - were linked to terrorism, he said a number of Somalis in the US had been connected to the al-Shabab group.

But at one point Mr Flentje said: "I'm not sure I'm convincing the court."

Media playback is unsupported on your device Media caption How travel ban prompted a heartfelt act of kindness

Then a lawyer representing Washington state told the court that halting the executive order had not harmed the US government.

Solicitor General Noah Purcell said the ban had affected thousands of residents of the state, with students delayed as they tried to come to Washington and others prevented from visiting family abroad.

He also urged the court to serve "as a check on executive abuses."

A Muslim ban or not?

The final minutes of the hearing were spent on whether the travel ban amounted to a shut-out for Muslims, which would be unconstitutional. Judge Richard Clifton asked both sides on the issue, pointing out it affected only 15% of the world's Muslims.

"I have trouble understanding why we're supposed to infer religious animus when in fact the vast majority of Muslims would not be affected," he said.

He also added that the "concern for terrorism from those connected to radical Islamic sects is hard to deny."

A 15-page brief issued by the Justice Department on Monday night argued the executive order was "neutral with respect to religion".

Media playback is unsupported on your device Media caption Lancaster, Pennsylvania: America's refugee capital

But in court on Tuesday, Mr Purcell cited Mr Trump's campaign statements about a Muslim ban. He also pointed to statements made by one of the president's advisers, Rudy Giuliani, who said he was asked to come up with a way of making a Muslim ban work legally.

Mr Clifton also said the seven countries included in the ban were identified by the Obama administration and Congress as deserving of visa restrictions, based on a terror threat.

He asked: "Do you assert that that decision by the previous administration and Congress as religiously motivated?"

No, Mr Purcell answered, but President Trump had called for a complete ban and although this was not a complete ban, it was discriminatory.

What did the executive order do?

Its main components were:

nationals from Iraq, Syria, Iran, Libya, Somalia, Sudan and Yemen - even those with visas - banned from entering the US;

a temporary ban on all refugee admissions;

the reprioritisation of minority religion (interpreted to mean Christian) refugee claims;

a ban on all Syrian refugees;

a cap on total annual refugee admissions to the US of 50,000.

It came into force on 27 January and caused some confusion at US and foreign airports because people were stopped from boarding planes or prevented from entering the US, and sent home.

There was strong condemnation and it was halted last Friday by a federal judge in Washington state.

As a result, people from the seven countries with valid visas were able to travel to the US again.

Washington state, Minnesota and other states want the appeals court in San Francisco to permit the temporary restraining order to stand as their lawsuit works its way through the courts.

Polls suggest that US public opinion is sharply divided on the issue.