Justice Kennedy’s final opinions on the court had a valedictory quality. He wrote an inconclusive decision in a clash between a baker and a gay couple, and he joined a pair of decisions ducking the question of whether the Constitution prohibits partisan gerrymandering.

Justice Kennedy valued civility and dignity, and the Trump years seemed to take a toll. In Tuesday’s decision upholding Mr. Trump’s travel ban, he seemed to chide the president for incivility even as he said the courts could do nothing to force him to behave with the decorum Justice Kennedy prized.

“There are numerous instances in which the statements and actions of government officials are not subject to judicial scrutiny or intervention,” he wrote. “That does not mean those officials are free to disregard the Constitution and the rights it proclaims and protects.”

“The oath that all officials take to adhere to the Constitution is not confined to those spheres in which the judiciary can correct or even comment upon what those officials say or do,” he wrote. “Indeed, the very fact that an official may have broad discretion, discretion free from judicial scrutiny, makes it all the more imperative for him or her to adhere to the Constitution and to its meaning and its promise.”

A new Trump appointee would almost certainly vote with the court’s most conservative members, thrusting Chief Justice Roberts into the court’s ideological center. The chief justice has drifted slightly to the left in recent years, but aside from two votes sustaining President Barack Obama’s health care law, it is hard to point to a major decision in which he disappointed political conservatives.

“Should Roberts become the median, the court could move well to the right, taking its place as the most conservative court in modern history,” Professor Epstein said.

In the Supreme Court term that just concluded, Chief Justice Roberts already seemed to be moving to the court’s center, voting with the majority in divided cases more often than any other justice. The term yielded an extraordinary run of conservative rulings, including blockbusters upholding Mr. Trump’s travel ban and dealing a sharp blow to public unions.