The Trump administration must restore the legal status of potentially hundreds of thousands of immigrants, a federal judge ruled Tuesday.