WASHINGTON — In the annals of Supreme Court history, a 1944 decision upholding the forcible internment of Japanese-Americans during World War II has long stood out as a stain that is almost universally recognized as a shameful mistake. Yet that notorious precedent, Korematsu v. United States, remained law because no case gave justices a good opportunity to overrule it.

But on Tuesday, when the Supreme Court’s conservative majority upheld President Trump’s ban on travel into the United States by citizens of several predominantly Muslim countries, Chief Justice John G. Roberts Jr. also seized the moment to finally overrule Korematsu.

“The forcible relocation of U.S. citizens to concentration camps, solely and explicitly on the basis of race, is objectively unlawful and outside the scope of presidential authority,” he wrote. Citing language used by then-Justice Robert H. Jackson in a dissent to the 1944 ruling, Chief Justice Roberts added, “Korematsu was gravely wrong the day it was decided, has been overruled in the court of history, and — to be clear — ‘has no place in law under the Constitution.’”

In a dissent of the travel ban ruling, Justice Sonia Sotomayor offered tepid applause. While the “formal repudiation of a shameful precedent is laudable and long overdue,” she said, it failed to make the court’s decision to uphold the travel ban acceptable or right. She accused the Justice Department and the court’s majority of adopting troubling parallels between the two cases.