For the second time this year, the contest to run an overwhelmingly Democratic city is resting in large part on whether one of the candidates is too cozy with organized labor, for decades the fuel that sustained the party’s candidates.

In Boston, a debate Tuesday night centered on attacks made by organized labor against John R. Connolly, and Connolly’s attempts to turn back the criticism on his rival, Martin J. Walsh, a longtime labor leader. Connolly painted a portrait of unions thrilled at the prospect of one of their own at the negotiating table, presumably to pull the chips their way: “It seems like they can’t wait to get you at the table,” Connolly told Walsh, and by extension Boston’s voting public.

It duplicated the tenor of Los Angeles’ spring mayoral contest, when Eric Garcetti, a longtime friend of labor himself, turned some unions’ support of his nemesis Wendy Greuel into an albatross that helped strangle the city controller. A USC/Los Angeles Times poll conducted before the election found that those who objected to public sector unions strongly favored Garcetti over Greuel. Despite -- or maybe because of -- millions spent on her behalf by the utility union and others, Greuel lost a race in which she had once been the front-runner.

She had once been ahead, ironically, because of her support from organized labor. It has become a navigational test for candidates in some Democratic cities, where historic support of organized labor has given way to resentment at the contracts awarded to public-sector unions even as the economy cratered. (Everywhere, it seems, private-sector unions are not the issue.) The bottom line in those places: A candidate needs enough support from organized labor to sustain a campaign but not so much that he or she is seen as a handmaiden.

Not every Democratic city is experiencing the same yin/yang; New York appears poised to overwhelmingly elect the left-leaningest of its Democratic candidates, Bill de Blasio, who has run a campaign that touts his desire to help the middle and lower classes keep what remains of their toehold in the city. But New York has been controlled by an anti-union mayor since Rudolph W. Giuliani was elected in 1993, tamping down some of the tension that has built in other cities.

It is not unusual for Democrats to change their tune in office. Rahm Emanuel has had nasty rows with organized labor since becoming Chicago’s mayor, including a teacher’s strike and multiple threats of job cutbacks during union negotiations. In Los Angeles, Garcetti’s predecessor, Antonio Villaraigosa, came into office after a career as a labor leader and a state legislator friendly to unions. He left office eight years later having become the target of City Hall protests for enforcing layoffs and furloughs, the cost of city fiscal difficulties made worse by bountiful contracts awarded to public-sector unions.

"I know how hard our employees work, and our teachers work; I just think there are things that are broken that they are defending and they can't continue to defend," Villaraigosa said as he left office. "We have to all shoulder the responsibility of setting ourselves on a more sustainable path, and I'm not intimidated by them, like some."

Still, he acknowledged, there would probably be a price to pay were he to find himself in a future contest against another Democrat more hospitable to organized labor.

The circumstances in Boston, like those in Los Angeles, encouraged the labor fight. In both cases, the candidates were fairly aligned on a host of issues, leaving their labor bona fides as one of the few areas of dispute.

In the Tuesday debate, the Boston Globe reported, Connolly raised the fiscal implications of Walsh’s loyalties after his long tenure with Boston’s building trades.

“I want police officers to be well-paid, and I want firefighters to be well-paid,” Connolly said. “But a mayor has to guard the fiscal health of the city. He’s got to be independent, and he’s got to make balanced decisions to benefit everyone.”

Walsh’s reply didn’t exactly put the matter to rest.

“I think there’s a clear difference here,” he said. “I respect the public employees that work for the city of Boston. John just mentioned about drawing a line. That line is not how you negotiate. You do it by transparency, respect, and you put the cards on the table so you can see exactly what’s out there and we can come up with a contract.”

One of the questions likely to come out of Nov. 5’s election: Is labor’s support still a benefit, or a cross to bear?