Ruling marks legal setback for administration's efforts to roll back protections for various groups of immigrants.