Image copyright Reuters Image caption The first ban was met by protests in airports across the US - in Dallas, Muslims prayed in protest

The US Supreme Court has upheld President Donald Trump's revised travel ban and overruled legal challenges from lower courts.

This is the government's third version of a controversial policy since Mr Trump took office in January.

Who is affected?

The latest presidential proclamation - which was issued in September - bans nationals of Iran, Libya, Somalia, Syria and Yemen from entering the US.

It also covers travellers from North Korea and certain government officials from Venezuela. But lower courts had already allowed those provisions to take effect.

Chad was removed from the list in April.

This third version of the travel ban has been in operation since December, when the Supreme Court allowed it to go into force as legal challenges went on.

What just happened?

The 5-4 ruling at the highest court in the US reverses a series of lower court decisions that had said the ban was unconstitutional.

It hands a major victory to President Trump, who made immigration a central plank of his campaign and introduced the first version of his travel ban just one week into office.

Chief Justice John Roberts gave the landmark opinion and the court's other four conservative judges also ruled in favour of the president.

The four liberal justices dissented.

What about the two previous versions of the ban?

The original order issued in January 2017 barred people from seven majority-Muslim countries - Iran, Iraq, Syria, Yemen, Somalia, Sudan and Libya - from entering the US for 90 days.

It also halted refugee resettlement for 120 days and banned Syrian refugees indefinitely.

Chaos ensued at airports, where there was some confusion about enforcement.

That travel ban was later blocked by federal courts.

The revised order in March removed Iraq from the list, after it agreed to boost co-operation with the US, and it also lifted the indefinite ban on Syrian refugees.

It was also struck down but in June 2017, the Supreme Court allowed that version of the policy to take partial effect, against travellers without close links to the US.

A third version of the ban was issued in September, taking Sudan off the list but adding Chad, North Korea and Venezuelan government officials.

Why were those countries chosen?

The latest travel ban says that the countries "remain deficient at this time with respect to their identity-management and information-sharing capabilities, protocols, and practices. In some cases, these countries also have a significant terrorist presence within their territory".

Critics have noted that major attacks such as the 9/11 New York attacks, the Boston marathon bombing and the Orlando nightclub attack were carried out by people from countries not on the list, such as Saudi Arabia, Egypt and Kyrgyzstan, or by US-born attackers.

Is it a 'Muslim ban'?

This was a crucial question in the legal battle, as six out of eight countries on the list are predominantly Muslim.

Media playback is unsupported on your device Media caption Muslim students on Trump ban: 'I don't belong here'

In one early challenge, a US district judge in Virginia ruled the first order was unconstitutional because it had religious bias at its heart - an appeals court in the same state ruled along the same lines on the second ban too.

Ruling on the second version, the Hawaii court also dismissed the government's argument that the ban is not anti-Muslim because it targets all individuals from the six countries, regardless of religion, and the countries themselves represent only a small fraction of the world's Muslim population.

"The illogic of the government's contentions is palpable. The notion that one can demonstrate animus toward any group of people only by targeting all of them at once is fundamentally flawed," the court ruling said, pointing out that the countries' populations were between 90% and 99% Muslim.

The court also cited statements made by Mr Trump, such as a 2015 press release calling for "a total and complete shutdown of Muslims entering the United States".

But the Department of Justice has said a distinction should be made between things said as a candidate and as president.