Marty Walsh rode labor, likability, and liberals to a narrow victory in Tuesday’s mayoral election. A former labor leader, Walsh got a big boost from local and national union dollars and from legions of union members who joined his canvassing and get-out-the-vote efforts.

Yet it sells Walsh short to say this was just about labor. His hidden advantage was always his sterling personal qualities. The Dorchester state representative is outgoing, sympathetic, a good listener, and all-around decent guy. After finishing first in the preliminary, Walsh quickly leveraged that likability into a string of endorsements — most notably from former rivals Charlotte Golar Richie, John Barros, and Felix Arroyo — that changed the dynamic of the race. Their nods gave him credibility with minority voters, while helping him emerge as the favorite of movement progressives.

John Connolly, who led in the polls immediately after the preliminary, had one primary message — the need for dramatic change in the Boston Public Schools — and one secondary one: He was independent enough to make those changes, while Walsh was not.

That pitch worked for moderates, reformers, and newspaper editorial boards, but it just as clearly drove much of the Democratic establishment into Walsh’s camp. For example, despite Walsh’s stated desire to lift the charter-school cap and renegotiate their existing contract to lengthen the school day, on election morning, the Boston Teachers Union urged its members to support him, saying he would be more collaborative with the union.

For his part, Walsh repeatedly assured voters that his strong relations with unions meant they could work together for important changes. That will be a challenge not just for him, but for labor as well. The big city unions often had contentious relationships with Tom Menino, hardly an anti-union mayor. Now that they’ve helped put their own favorite in City Hall, those unions need to show that they really can be part of the solution.