When applied to Americans, such a policy would almost certainly violate constitutional guarantees of "due process of law" and "equal protection."
But legal scholars note that immigration law is different, and Trump's ban, however controversial, could actually pass legal muster.
Federal law and the courts have long given Congress and the president nearly unchecked power to bar foreigners from entering the country.
"Whenever the president finds that the entry of any aliens or of any class of aliens into the United States would be detrimental to the interests of the United States, he may by proclamation, and for such period as he deems necessary, suspend the entry of all aliens or any class of aliens," according to the federal Immigration and Nationality Act.
Moreover, non-citizens who live outside the U.S. usually cannot invoke rights protected by the Constitution.
After the initial public uproar, Trump quickly clarified that he did not mean to include U.S. citizens in the ban and was referring only to foreigners.
For its part, the Supreme Court throughout history has steadily upheld the federal government's so-called "plenary power" over immigration.
In 1889, for example, the justices upheld the Chinese Exclusion Act, which kept out Chinese laborers and declared that the "power of exclusion of foreigners" was a "part of the sovereign powers delegated to" the federal government. That decision remains on the books.
In June of this year, the high court upheld the State Department's decision to deny a visa to the Afghan husband of a California woman. Fauzia Din, a U.S. citizen living in Fremont, was asking the court to require immigration officials to give a better explanation for why her husband’s visa was denied, but Justice
University of Chicago Law Professor Eric Posner said the "plenary power" doctrine is viewed with contempt by many lawyers, but because of legal precedents it has set, civil libertarians would face an uphill fight if they challenged a broad immigration ban in the Supreme Court.
"If you take seriously the cases that have been decided in the past, they would find it constitutional," he said of a Trump-like ban on Muslims. Though past restrictions have been based on race, nationality or political beliefs — not religion — Posner said he did not see that distinction as crucial.
"As a matter of law, I don't see why it should matter," he said. "If someone can be excluded from this country merely for having the wrong political beliefs, he could be excluded for having the wrong religious beliefs."
But he and other legal scholars agree that some members of the current high court -- including Justice
"If a restriction on Muslims were to become law, it would not surprise me to see the courts strike it down as irrational -- and probably because it sweeps too broadly," said UCLA law professor Hiroshi Motomura, who teaches immigration law.
Other legal experts said religion is a bit of a wild card. The high court in the past has not ruled directly on mass exclusions based on religion, and today's justices are particularly sensitive to discrimination based on religion.
Earlier this year, the high court with near unanimity ruled for a Muslim girl who had been turned down for a sales job because she wore a head scarf at the job interview, and for a Muslim inmate whose beard violated prison rules. Justice
"Religion is one of the few areas that crosses the left-right divide. It is a point of common cause," said Stephen Vladeck, a law professor at American University in Washington.
"The people who say this will be easily upheld are missing the reality of the current court's views on religion," he said.
And most agree such any ban could be enforced only against immigrants.
"The plenary power doctrine applies only to foreigners," Posner said. "If [Trump] really tried to ban Muslim Americans from entering the United States, the courts would almost certainly rule against him."
On Twitter: @DavidGSavage