The decision marks an uncommon setback for Trump at the high court, where his administration has frequently prevailed.