Donald Trump hailed a US Supreme Court ruling a "great victory" after it voted to uphold the US president's travel ban on some Muslim majority countries.
The court voted 5-4 to uphold the ruling which Mr Trump made in his first week in office in January 2017.
"Today's Supreme Court ruling is a tremendous victory for the American people and for our constitution. This is a great victory for our constitution." Mr Trump said.
"We have to be tough. We have to be safe. We have to be secure."
Chief Justice John Roberts wrote the majority opinion, saying that presidents have substantial power to regulate immigration.
The Supreme Court judge was joined by his four conservative colleagues in voting along ideological grounds to uphold the order.
Mr Roberts rejected the challenger's claim of anti-Muslim bias, but was careful not to endorse any of Mr Trump's provocative statements.
President Trump tweeted shortly after the ruling:
Mr Trump's order was challenged on the grounds that he had exceeded his authority and violated the constitution by targeting Muslims.
The executive order banned travel from seven countries, five of which were Muslim-majority. In total the ban bars more than 150 million people from entering the United States.
The travel ban, in its current form, prevents travel from Iran, Libya, Somalia, Syria, and Yemen. North Korea and some officials from Venezuela are also targeted.
In January 2017, the order sparked protests outside airport terminals across the US, and was quickly subject to legal challenges.
Writing in dissent, Justice Sonia Sotomayor said, "a reasonable observer would conclude that the Proclamation was motivated by anti-Muslim animus."
Mrs Sotomajor said her conservative colleagues arrived at the opposite result by "ignoring the facts, misconstruing our legal precedent, and turning a blind eye to the pain and suffering the Proclamation inflicts upon countless families and individuals, many of whom are United States citizens."
Justices Stephen Breyer, Ruth Bader Ginsburg and Elena Kagan also dissented.