Updated

The Supreme Court has upheld the Trump administration’s controversial travel ban that affected a handful of Muslim-majority nations.

In what is the first substantive ruling on a Trump administration policy, Chief Justice John Roberts, writing for the majority, said presidents have substantial power to regulate immigration.

President Trump announced the 5-4 ruling in a tweet, adding the exclamation, “Wow!”

In a longer statement, the White House called the decision a “tremendous victory for the American People and Constitution.”

“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.”

Sen. Tom Cotton, R-Ark., said in a statement: “Congress has long delegated to the president the authority to regulate the entry of people into the United States, particularly from war-torn countries or well-known state sponsors of terrorism.

“The Court has rightly upheld this common-sense, longstanding practice, which I hope will end once and for all the tortured reasoning of liberal judges who make up new legal doctrines because they personally disapprove of the president.”

Rep. Steve Scalise, R-La., said the Supreme Court made the “right decision.” He said the president “ran on putting American first again and standing up to keep our country safe. That’s exactly what this policy does, and today’s ruling affirms that authority.”

Sen. Ed Markey, D-Mass., blasted the “Republican-controlled Senate” for having stolen a Supreme Court seat with the nomination of Justice Neil Gorsuch, who he called an “archconservative.” He said the bench is “now enshrining Donald Trump’s legacy of hate” with Tuesday’s decision.

Connecticut Sen. Chris Coons said he plans to introduce legislation soon “to make clear” that the U.S. does “not tolerate discrimination based on religion or nationality” in the wake of the decision.

TRUMP TRAVEL BAN: TIMELINE OF A LEGAL JOURNEY

“The Supreme Court may have ruled that the President’s travel ban was technically constitutional, but that doesn’t mean that it’s right, that it’s justified or that it reflects America’s values,” the Democrat said in a statement.

“The President’s travel ban is not only discriminatory and counterproductive; it stands in direct contrast to the principles embedded in our Constitution and our founders’ vision of a nation where all people are free to worship as they choose,” he added. “With time, we have made our union more perfect by fighting discrimination in all of its forms, but the Court’s decision today demonstrates that we have a long way to go before we live up to our highest ideals.”

Rep. Linda Sanchez, D-Calif., said, “It is extremely disappointing that the Supreme Court upheld this shameful stain on our country. America should be better than this. History will not be kind to this decision.”

A LOOK AT THE MAJOR CASES ON THE SUPREME COURT’S AGENDA

After the decision, Rep. Barbara Lee, D-Calif., said it was a “dark day in America.” She said it will be “remembered as a stain on our nation and an abdication of our fundamental American values.”

Rep. Salud Carbajal, also a California Democrat, said he was “disappointed” by the decision and promised to “continue fighting against discriminatory and hateful immigration policies.”

Trump’s travel ban “is a serious attack on religious freedom on America,” said Rep. Tim Walz, D-Minn. “Today’s Supreme Court decision does not reflect our American values.”

“What is legal is not always just. A narrow ruling on whether or not the President of the United States is in possession of the statutory authority to implement this policy avoids the basic question of whether or not it’s the right thing to do,” Sen. Brian Schatz, D-Hawaii, said in a statement.

He added that the nation’s highest court “made the wrong decision and ignored the evidence that the Muslim ban, even the more narrowly tailored version, is a xenophobic policy.”

Other lawmakers reacted on social media.

Fox News’ Bill Mears, Caitlyn Richard and The Associated Press contributed to this report.