The ruling is the latest twist in a case that has become emblematic of President Trump's mass deportation campaign.