“Look at all of our mayors over the years,” Mr. Small said. “Look at all the names.”

Walsh. Menino. Flynn. And those are only the most recent.

One of them, Ray Flynn, who later became President Bill Clinton’s ambassador to the Vatican, said the outcome on Tuesday was a welcome signal of a new power structure in the city, even as it followed a familiar arc.

“It’s like the old days,” Mr. Flynn said. “The Irish came into political power. And then the Italians. And then the Polish. And now you’re seeing the immigrant population and the minorities, they’re starting to get some real political strength in Boston. That’s a good thing. That means that they really feel empowered. They feel like they’re part of Boston.”

Taking stock of the fallout on Wednesday, local Democrats vacillated between shock and exuberance. (There was also a bit of justifiable fatigue. After saying she had spent much of the last several months double-fisting coffee and energy drinks, Ms. Pressley canceled an afternoon event, with her campaign citing “some symptoms of dehydration and exhaustion.”)

The gathering in Dorchester, held at Senator Elizabeth Warren’s Boston headquarters, was billed as a “unity event,” and attended by fellow Democrats who may or may not have supported Ms. Pressley’s bid initially. Mayor Martin J. Walsh, who had backed Mr. Capuano, said that Ms. Pressley’s campaign had left people “inspired to make history.”

Maura Healey, the state’s popular attorney general, who had worked on behalf of Ms. Pressley, remarked upon the number of first-time candidates across the ballot on Tuesday. “And you know what?” she said. “A whole bunch of them won. That’s what democracy looks like.”

In what was seen as a victory of sorts for Ms. Pressley during the campaign, both United States senators from Massachusetts — Ms. Warren and Ed Markey — had remained neutral in the race.