The ruling allowed immigration agents to stop people for reasons that lower courts had deemed likely unconstitutional.