SCOTUS has unequivocally held that any grounds may be used for immigration bans

With due respect to my colleague Jonathan Keiler, it appears he may have misunderstood U.S. constitutional law when stating the following:

Nobody expects a president to be a constitutional scholar. If our current chief executive is any guide it ought to be considered disqualifying – though Obama's claims to constitutional knowledge and scholarship are actually much thinner than the parchment upon which that document is written.  So Donald Trump's lack of constitutional erudition is not in itself terribly disturbing. What's more problematic is his seeming lack of interest in the topic, and as is the case in other areas, a stubborn unwillingness to learn. Trump, on the other hand, has been winging it successfully so far, at least as a political matter, but this trait is coming back to bite him, as it did recently on the issues of guns and Muslims[.]

Banning Muslim immigrants logically ought to reduce the risk of such terrorism.

However, it is a position that simply cannot be defended constitutionally. The constitution prohibits discrimination on the basis of religion. A law that effectively bans one confessional group from entering the United States, and thereby obtaining a path to citizenship, will not pass constitutional muster.  The formula that most terrorists are Muslim, but that most Muslims are not terrorists -- which also states an objective truth -- produces a result that makes banning Muslim immigration legally indefensible, no matter how satisfying it may be on an emotional or practical level.

In fact, as has been acknowledged even in the mainstream media by constitutional law experts, Trump appears to be on solid constitutional ground when calling for a Muslim immigration ban.

David Cole, the George J. Mitchell professor in law and public policy and an expert in constitutional and national security law at Georgetown University, was unequivocal in his review article:

On the other hand, the [Supreme] Court [of the United States] has permitted foreign nationals to be excluded and expelled because of their race. It has allowed them to be deported for political associations that were entirely lawful at the time they were engaged in. It has upheld laws barring foreign nationals from owning land ... It has permitted the indefinite detention of "arriving aliens" stopped at the border on the basis of secret evidence that they could not confront. And it has allowed states to bar otherwise qualified foreign nationals from employment as public school teachers and police officers, based solely on their status as foreigners.

The two key cases supporting a constitutional right to discriminate based on race are the "Japanese Immigrant Case" (Yamataya v. Fisher 189 U.S. 86 [1903]) and the "Chinese Exclusion Case" (Chae Chan Ping v. United States 130 U.S. 581 [1889]).

In Yamataya v. Fisher, the Supreme Court spoke in no uncertain terms:

The constitutionality of the legislation in question, in its general aspects, is no longer open to discussion in this court. That Congress may exclude aliens of a particular race from the United States; prescribe the terms and conditions upon which certain classes of aliens may come to this country; establish regulations for sending out of the country such aliens as come here in violation of law; and commit the enforcement of such provisions, conditions, and regulations exclusively to executive officers, without judicial intervention, are principles firmly established by the decisions of this court. Nishimura Ekiu v. United States, 142 U.S. 651 , 35 L. ed. 1146, 12 Sup. Ct. Rep. 336; Fong Yue Ting v. United States, 149 U.S. 698 , 37 L. ed. 905, 13 Sup. Ct. Rep. 1016; Lem Moon Sing v. United States, 158 U.S. 538 , 39 L. ed. 1082, 15 Sup. Ct. Rep. 967; Wong Wing v. United States, 163 U.S. 228 , 41 L. ed. 140, 16 Sup. Ct. Rep. 977; Fok Yung Yo v. United States, 185 U.S. 296, 305 , 46 S. L. ed. 917, 921, 22 Sup. Ct. Rep. 686, 690 ...

It is not within the province of the judiciary to order that foreigners who have never been naturalized, nor acquired any domicil or residence within the United States, nor even been admitted into the country pursuant to law, shall be permitted to enter, in opposition to the constitutional and lawful measures of the legislative and executive branches of the national government. As to such persons, the decisions of executive or administrative officers, acting within powers expressly conferred by Congress, are due process of law. Den ex dem. Murray v. Hoboken Land & Improv. Co. 18 How. 272, 15 L. ed. 372; Hilton v. Merritt, 110 U.S. 97 , 28 L. ed. 83, 3 Sup. Ct. Rep. 548.

Similarly, in Chae Chan Ping v. United States, the court was clear as to the law:

That the government of the United States, through the action of the legislative department, can exclude aliens from its territory is a proposition which we do not think open to controversy. Jurisdiction over its own territory to that extent is an incident of every independent nation. It is a part of its independence.

If it could not exclude aliens, it would be to that extent subject to the control of another power. As said by this Court in the case of The Exchange, 7 Cranch 116, 11 U. S. 136, speaking by Chief Justice Marshall:

"The jurisdiction of the nation within its own territory is necessarily exclusive and absolute. It is susceptible of no limitation not imposed by itself. Any restriction upon it deriving validity from an external source would imply a diminution of its sovereignty to the extent of the restriction and an investment of that sovereignty to the same extent in that power which could impose such restriction. All exceptions, therefore, to the full and complete power of a nation within its own territories must be traced up to the consent of the nation itself. They can flow from no other legitimate source." ...

To preserve its independence, and give security against foreign aggression and encroachment, is the highest duty of every nation, and to attain these ends nearly all other considerations are to be subordinated. It matters not in what form such aggression and encroachment come, whether from the foreign nation acting in its national character, or from vast hordes of its people crowding in upon us. The government, possessing the powers which are to be exercised for protection and security, is clothed with authority to determine the occasion on which the powers shall be called forth, and its determinations, so far as the subjects affected are concerned, are necessarily conclusive upon all its departments and officers. If, therefore, the government of the United States, through its legislative department, considers the presence of foreigners of a different race in this country, who will not assimilate with us, to be dangerous to its peace and security, their exclusion is not to be stayed because at the time there are no actual hostilities with the nation of which the foreigners are subjects. The existence of war would render the necessity of the proceeding only more obvious and pressing. The same necessity, in a less pressing degree, may arise when war does not exist, and the same authority which adjudges the necessity in one case must also determine it in the other. ...

The power of the government to exclude foreigners from the country whenever in its judgment the public interests require such exclusion has been asserted in repeated instances, and never denied by the executive or legislative departments. ...

The power of exclusion of foreigners being an incident of sovereignty belonging to the government of the United States as a part of those sovereign powers delegated by the Constitution, the right to its exercise at any time when, in the judgment of the government, the interests of the country require it, cannot be granted away or restrained on behalf of anyone.

The powers of government are delegated in trust to the United States, and are incapable of transfer to any other parties. They cannot be abandoned or surrendered. Nor can their exercise be hampered, when needed for the public good, by any considerations of private interest. The exercise of these public trusts is not the subject of barter or contract.

There is no debate.

The Supreme Court of the United States has repeatedly held that any grounds can be employed to restrict immigration based on any factor, be it race, religion, country of origin, or otherwise.

Jonathan Keiler responds:

The constitutionality of a ban on Muslim immigration is not nearly as cut and dried as Mr. Rayne would like to believe, and legal experts have come down on both sides of the issue.  While the Chinese Exclusion Act, related legislation and some very old Supreme Court opinions suggest that such a ban would be legal, under the rubric of the nation’s “absolute” ability to exclude foreigners, an actual exclusion on purely religious grounds has not been litigated and would seem to obviously run afoul of the Constitution’s prohibition against the establishment of religion and on religious tests.  I believe Trump’s proposal is unconstitutional, and I also think it is laughable to believe that the precedents of the Exclusion Act and Supreme Court decisions upholding it will survive analysis by modern courts, to include today’s Supreme Court.  Precedents are overturned all the time, and this one would not survive long once challenged.