The mayor has bet his popularity and influence to push Democratic Socialist allies into office.