President Trump claimed victory and vindication Tuesday after the Supreme Court ruled 5 to 4 to uphold his administration’s ban on travelers from a handful of majority-Muslim countries.

The ruling affirms one of Trump’s signature policies, which he instituted via executive order a few days after taking office, and was received inside the White House as a substantial political and legal triumph after 17 months of court battles.

“Wow!” the president tweeted Tuesday, minutes after the court’s decision.

Trump then took a victory lap, taking a moment at the start of a meeting with Republican lawmakers to celebrate what he called “a tremendous victory for the American people and for our Constitution.” He said the court’s ruling was “pretty much the final word.”

The president defended his hard-line immigration and travel policies, saying: “We have to be tough, and we have to be safe, and we have to be secure. At a minimum, we have to make sure that we vet people coming into the country.”

Earlier Tuesday, Trump said in an official statement issued by the White House, “Today’s Supreme Court ruling is a tremendous victory for the American People and the Constitution. The Supreme Court has upheld the clear authority of the President to defend the national security of the United States. In this era of worldwide terrorism and extremist movements bent on harming innocent civilians, we must properly vet those coming into our country.”

Trump went on to chide his perceived enemies for having called his travel ban unconstitutional and an overreach of his presidential powers.

“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,” Trump said. “As long as I am President, I will defend the sovereignty, safety, and security of the American People, and fight for an immigration system that serves the national interests of the United States and its citizens. Our country will always be safe, secure, and protected on my watch.”

Inside the West Wing on Tuesday, there was an air of vindication and even elation among the president and his senior aides as cable television shows broke in with breaking news bulletins announcing the Supreme Court’s ruling.

“People really criticized the order, its implementation, they really criticized what the president was trying to do, they knee-jerk called it a ‘Muslim ban,’ and a lot of the counter arguments based on facts were falling on deaf ears,” said one senior White House official, who requested anonymity to speak candidly. “The media and critics weren’t listening. Hopefully they will now.”

Donald Trump Jr., the president’s eldest son, voiced a similar sentiment as he retweeted a news account of the court’s ruling with the comment: “So, let me get this straight, youre saying it was constitutional all along?”

Justice Neil M. Gorsuch, whom Trump nominated early last year to fill a vacancy on the Supreme Court, was seen as a crucial vote with fellow conservative justices in upholding the travel ban. Senate Majority Leader Mitch McConnell (R-Ky.) celebrated Tuesday’s ruling by tweeting from his campaign account a photograph of himself shaking hands with Gorsuch.

Stephen K. Bannon, who as chief White House strategist was an architect of the travel ban, said Tuesday that the court’s ruling vindicated Trump and his administration after receiving a year and a half of attacks from the political left over the policy.

“Donald Trump ran on and won because of his commitment to keep America safe,” Bannon said in a statement. “Today’s Supreme Court ruling on his travel ban is a vindication of the president, his administration and the will of the American people.”