His candidacy stoked tensions among Democrats over gender and how to win back working-class voters.