The US Supreme Court has ruled in favour of the Trump administration's travel ban targeting people from several Muslim-majority countries.
Lower courts had deemed the ban unconstitutional, but the US top court has reversed this decision in a 5-4 ruling announced on Tuesday.
The ban prohibits most people from Iran, Libya, Somalia, Syria and Yemen from entering the US.
The court's reversal is viewed as a victory for the Trump administration.
But the travel ban has been widely criticised by refugee and human rights groups.
Chief Justice John Roberts wrote the opinion, which said the travel ban was “squarely within the scope of Presidential authority”.
“The Government has set forth a sufficient national security justification to survive rational basis review. We express no view on the soundness of the policy.”
Shortly after the Supreme Court released its decision, President Donald Trump Trump shared the news from his Twitter account.
Omar Jadwat, director of the American Civil Liberties Union (ACLU) Immigrant Rights Project said in a statement that the ruling was one of the Court's “great failures”.
“The court failed today, and so the public is needed more than ever. We must make it crystal clear to our elected representatives: If you are not taking action to rescind and dismantle Trump's Muslim ban, you are not upholding this country's most basic principles of freedom and equality.”
Mr Jadwat likened the Court's decision to the ruling which upheld Japanese-American internment during World War Two.
Analysis by Anthony Zurcher, BBC News
Despite the controversial nature of Donald Trump's travel ban, there were more abortion rights activists outside the Supreme Court on Tuesday morning than immigration protesters.
Perhaps it's because abortion has been a contentious legal battle for decades, while the president's travel directive had been in effect, and out of the headlines, for months.
Attention in recent weeks has been on migrants coming across the southern US border, not visitors and prospective residents from countries like Libya, Iran, Yemen and Syria.
Nevertheless, this marks a significant victory for Mr Trump – and for presidential power to set immigration policy in general – albeit by the narrowest of margins.
The five court justices said they took the president's order on its face, and separated it from his more bombastic anti-Muslim comments made on the presidential campaign trail and via Twitter.
The travel ban was implemented haphazardly at the start of the Trump administration and faced repeated setbacks from the US legal system. In the end, however, the president got his way – or at least enough of his way to claim success.
The third time turned out to be the charm.
Mr Trump's ban has seen several iterations. Iraq and Chad were banned in previous versions, but have since been removed.
The administration says that the countries on the ban “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”.
The state of Hawaii had challenged the ban and a federal judge blocked its implementation.