US President Donald Trump.

The US Supreme Court on Tuesday upheld President Donald Trump’s controversial order which prevents the nationals of several Muslim-majority nations from entering the country.

The nine-judge court voted 5-4 in favour of the ban.

“The proclamation is expressly premised on legitimate purposes: preventing entry of nationals who cannot be adequately vetted and inducing other nations to improve their practices,” Chief Justice John G Roberts wrote for the majority opinion. “The text says nothing about religion.”

Trump called the ruling “a tremendous victory for the American people and the Constitution”, saying in a statement that the court had “upheld the clear authority of the President to defend the national security” of the US.

His statement said: “This ruling is also a moment of profound vindication following months of hysterical commentary from the media and Democratic politicians who refuse to do what it takes to secure our border and our country.”

The order restricts the entry of people from Iran, North Korea, Syria, Libya, Yemen, Somalia and Venezuela. Chad was originally on the list but was removed after having met baseline security requirements.

Trump had announced his first travel ban through a hastily drafted executive order just a week after taking office in January 2017, triggering a global uproar. That order and the subsequent two were all struck down by lower courts. Tuesday’s Supreme Court ruling reverses that decision.

Rights groups immediately criticised the ruling.

The American Civil Liberties Union said the ruling will “go down in history as one of the Supreme Court’s greatest failures”.

Neal Katyal, an Indian-American Supreme Court lawyer who represented the state of Hawaii and other challengers, said he’s disappointed with the decision, adding that Trump should not to take the ruling as “approval to continue attacking our Constitution”.

Even dissenting judges voiced their disapproval. “Based on the evidence in the record, a reasonable observer would conclude that the Proclamation was motivated by anti-Muslim animus,” Supreme Court justice Sonia Sotomayor wrote in the dissent opinion.

Tom Perez, the chairman of the Democratic National Convention, did not criticise the court, choosing to focus on the travel order. He said: “Discrimination is not a national security strategy, and prejudice is not patriotism. Let’s call this ban for what it is: an outright attack on the Muslim community that violates our nation’s commitment to liberty and justice for all.”