Zohran Mamdani, the socialist state lawmaker running for New York City mayor, held an earlier lead over the former governor.