The 34-year-old assemblyman won the Democratic primary by defying the city’s all-powerful establishment. He secured the mayoralty by delicately disarming it.