WASHINGTON — A closely divided Supreme Court on Friday rejected President Donald Trump’s plan to immediately bar asylum claims from immigrants who crossed the border illegally.

By a 5-4 vote, but without additional comment, the court said it had denied the president’s request to set aside the rulings of a federal judge in San Francisco. The judge had blocked Trump’s order on asylum from taking effect, prompting the president to denounce him as an “Obama judge.”

Chief Justice John G. Roberts Jr. voted with the court’s four liberals to deny the emergency appeal filed by Solicitor General Noel Francisco.

For apparently the first time, new Justice Brett M. Kavanaugh cast a dissenting vote. Along with conservative Justices Clarence Thomas, Samuel A. Alito and Neil M. Gorsuch, he voted to grant the appeal, lift the judge’s order and allow Trump’s new policy to be enforced.

Lawyers for the ACLU who sued to stop Trump’s order argued that they had the law on their side.

In the Refugee Act of 1980, Congress opened the door wide for asylum claims from those who said they were fleeing persecution. “Any alien who is physically present in the United States or who arrives in the United States, where or not at a designated port of entry … irrespective of such alien’s status, may apply for asylum.”

But early last month, as both the midterm elections and a caravan of Central Americans approached, Trump issued a proclamation to sharply limit asylum claims, except for those who presented themselves at a designated port of entry. The president’s lawyers said the “crisis at the southern border” justified a change in policy.

Immigrants rights advocates said the president did not have the legal authority to change the law on his own. The ACLU sued on behalf of several humanitarian groups based in California, and U.S. District Judge Jon Tigar in San Francisco said Trump’s order conflicted with federal law and could not take effect. The 9th Circuit Court of Appeals in a 2-1 decision agreed and said that Trump’s order should remain on hold pending further proceedings.

“Just as we may not, as we are often reminded, ‘legislate from the bench,’ neither may the executive legislate from the Oval Office,” Judge Jay Bybee, a conservative appointee of President George W. Bush, wrote for the appeals court majority.

Trump’s solicitor general, Francisco, who has repeatedly gone to the Supreme Court seeking immediate relief from lower court rulings, appealed again to the high court, saying that “the nationwide injunction is deeply flawed and should be stayed pending appeal.”

But the justices rejected that appeal, keeping Trump’s order on hold.

ACLU attorney Lee Gelernt praised the decision.

“The Supreme Court’s decision to leave the asylum ban blocked will save lives and keep vulnerable families and children from persecution,” he said. “We are pleased the court refused to allow the administration to short-circuit the usual appellate process.”

Earlier this week, a federal judge in Washington rejected a different Trump administration restriction on asylum.