Voters in New York City and Boston on Tuesday chose two Democratic mayoral candidates who represent archetypes of the party’s activist-government, labor-dominated past.

Both mayors-elect ran on a platform of economic opportunity and fairness — an issue that resonates more among Democrats at a national level in the wake of the Great Recession. New York’s Bill de Blasio and Boston’s Martin Walsh share a strain of economic populism with some of the party’s more liberal members in Washington, like Sens. Elizabeth Warren (D-Mass.) and Sherrod Brown (D-Ohio).

De Blasio, New York’s public advocate, won more than 70 percent of the vote after pledging to address the growing wealth disparity between the city’s richest and poorest residents.

And Boston voters opted for Walsh, a Democratic state representative and former top labor leader, over City Council member John Connolly by 52 percent to 48 percent.

The two winners prevailed by drawing comparisons with their predecessors — although in very different ways.

De Blasio outlasted several Democrats with closer ties to business and the city’s financial sector in the Sept. 10 primary, in part by drawing stark contrasts between himself and the policies advanced by incumbent Mayor Michael R. Bloomberg (I). De Blasio opposed the city’s “stop-and-frisk” policy, which Bloomberg championed, and cast himself as a clean break from Bloomberg’s 12 years in office.

Exit polls conducted Tuesday showed Big Apple voters still approve of the job Bloomberg is doing as mayor but think that the city should move on. Just 26 percent of voters said the city should continue in the direction Bloomberg has set, while 69 percent said the city should move in a new direction. De Blasio won 85 percent of those voters. And 55 percent said the stop-and-frisk policies are excessive, while just 39 percent said the policy is acceptable.

Walsh, on the other hand, cast himself as the natural successor to longtime Mayor Thomas M. Menino, who remains a popular figure across Boston. There were few policy differences between Walsh and Connolly, although Walsh’s common-man story, and support from three nonwhite candidates who lost the primary election, helped him appeal to broad coalitions of minority voters in a city that has grown more diverse since Menino won office two decades ago.

In his victory speech at a downtown Boston hotel, Walsh pledged to work for “opportunity, because every woman, man and child deserves a chance,” the Boston Globe reported. Walsh said he will build Boston into a “community of shared prosperity.”

The two elections were chances for New York and Boston voters to chart a new direction after long tenures by familiar mayors. Menino has served five terms in office, while Bloomberg is completing his third. His replacement, de Blasio, is the first Democrat to win a mayoral election since David Dinkins in 1989.

“There is a lot of uncertainty right now in how big cities will operate, a lot of complicated issues that are still very much being figured out. It is natural for voters to go with candidates that they feel support positions they know and are comfortable with,” said Brian Reich, a communications strategist and managing director of New York-based Little M Media. “And in both Boston and New York, there are plenty of voters who fit that liberal label, so their comfort zone is going to look like an endorsement of old-line liberalism.”

In other races around the country Tuesday, mayors in Atlanta, Houston, Cleveland and Buffalo easily won reelection. In Cincinnati, former City Council member John Craney defeated Vice Mayor Roxanne Qualls with 58 percent of the vote in a race that largely revolved around a controversial $133 million streetcar proposal that Craney opposed.

Seattle voters chose state Sen. Ed Murray, a longtime fixture in state politics, over first-term Mayor Mike McGinn, who won four years ago in an upset and who was never popular with the city’s political establishment. McGinn is Seattle’s third consecutive mayor to not win reelection; Murray will be the city’s first openly gay mayor.

Seattle mayoral elections have in the past come down to contests between the candidates perceived to represent “downtown” interests and the candidates that supposedly are more aligned with the “neighborhoods.” In a twist, it was McGinn, the incumbent, who cast himself as the neighborhood candidate, while Murray spent a lot of time defending his progressive bona fides.

Both candidates pledged to raise the city’s minimum wage to $15 an hour.

Polls both public and private showed Murray winning by wide margins. But in the final days of the race, the polls narrowed after a Washington Post report that several large telecom firms had begun donating to Murray as McGinn pushed for more access to high-speed Internet throughout Seattle. A top Murray strategist told The Post that the report, which received significant attention in local media, helped narrow the contest.

In St. Petersburg, Fla., former city council member Rick Kriseman, once considered a long shot, defeated Mayor Bill Foster on Tuesday by 56 percent to 44 percent. Foster is the first mayor to lose his job since St. Petersburg transitioned to a strong-mayor format in 1993, the Tampa Bay Times reported. While the race was officially nonpartisan, Kriseman had support from local Democratic groups and elected officials. Foster had support from the state Republican Party.