The United States Supreme Court on Thursday rejected Donald Trump’s effort to end legal protections for 650,000 young immigrants often referred to as Dreamers, a stunning rebuke to the U.S. president amid his re-election campaign.

The outcome seems certain to elevate the issue in Trump’s campaign, given the anti-immigrant rhetoric of his first presidential run in 2016 and immigration restrictions his administration has imposed since then.

Chief Justice John Roberts sided with the liberal wing of the court in a 5-4 decision. Roberts, citing the Administrative Procedure Act, called the administration’s reasoning for ending the protections “arbitrary and capricious.”

The justices rejected administration arguments that the eight-year-old Deferred Action for Childhood Arrivals program (DACA) is illegal and that courts have no role to play in reviewing the decision to end it.

The 5-4 outcome, in which Chief Justice John Roberts and the four liberal justices were in the majority, seems certain to elevate the issue in Trump’s campaign, given the anti-immigrant rhetoric of his first presidential run in 2016 and immigration restrictions his administration has imposed since then.

The justices rejected administration arguments that the 8-year-old Deferred Action for Childhood Arrivals Program is illegal and that courts have no role to play in reviewing the decision to end DACA. The program covers people who have been in the United States since they were children and are in the country illegally. In some cases, they have no memory of any home other than the U.S.

Trump didn’t hold back in his assessment of the court’s work, hitting hard at a political angle.

“These horrible & politically charged decisions coming out of the Supreme Court are shotgun blasts into the face of people that are proud to call themselves Republicans or Conservatives. We need more Justices or we will lose our 2nd Amendment & everything else. Vote Trump 2020!” he wrote on Twitter, apparently including the LGBT ruling as well.

In a second tweet, he wrote, “Do you get the impression that the Supreme Court doesn’t like me?

The Supreme Court fight over DACA played out in a kind of legal slow motion. The administration first wanted the justices to hear and decide the case by June 2018. The justices said no. The Justice Department returned to the court later in 2018, but the justices did nothing for more than seven months before agreeing a year ago to hear arguments. Those took place in November and more than seven months elapsed before the court’s decision.

Thursday’s ruling was the second time in two years that Roberts and the liberal justices faulted the administration for the way it went about a policy change.