The ruling means 530,000 migrants from Cuba, Haiti, Nicaragua and Venezuela are at risk of being deported.