Jake Auchincloss, a moderate Democrat and local city councilor who was a registered Republican as recently as President Barack Obama’s second term, has won Tuesday’s nine-way Democratic primary in Massachusetts’s Fourth Congressional District to become the likely successor to the outgoing Representative Joseph P. Kennedy III.
Mr. Auchincloss won the highly fragmented race with less than 23 percent of the vote, The Associated Press reported early Friday morning, beating the second-place finisher, Jesse Mermell, a progressive endorsed by Representative Ayanna Pressley, by just over 2,000 votes.
The seat, which includes areas in the Boston metropolitan region like Brookline as well as towns to the south, opened unexpectedly after Mr. Kennedy decided to mount a primary challenge to Senator Edward J. Markey, who prevailed on Tuesday in one of the country’s most bitter intraparty fights.
In Mr. Auchincloss, 32, Massachusetts is replacing a scion of a political dynasty with another descendant of the political upper crust. His family tree includes Jackie Kennedy and Gore Vidal. Mr. Auchincloss is currently a city councilor in Newton, and did not shy away from his Republican past, tying himself to the state’s Republican governor, Charlie Baker.
The race was shaped by several small controversies. Mr. Auchincloss apologized for old statements on social media that seemed to justify the burning of the Quran. He also mocked efforts by a local community to rename Columbus Day “Indigenous Peoples’ Day” in 2016.
And yet, while Mr. Auchincloss trailed candidates in the Boston suburbs, he consolidated support in the heavily Democratic district’s southern regions. There, he cast himself in the image of Mr. Baker, the popular governor who has distanced himself from national Republicans such as President Trump.
“I’m honored that the people of #MA04 have chosen me as the Democratic nominee for Congress,” he said on Twitter. “My deepest gratitude goes out to the voters who placed their confidence in my capacity to drive progress — and to the volunteers and supporters who shared our message across their cities and towns.”
Mr. Auchincloss, who is expected to defeat the Republican nominee, Julie Hall, in November, is set to join an all-Democratic congressional delegation in Massachusetts that has a foothold in several of the party’s most important factions.
Mr. Markey remains in the ranks of progressives such as Senator Elizabeth Warren and Ms. Pressley. There are moderates who earn the ire of the party’s left, such as Representatives Stephen Lynch and Richard Neal — who both easily held their seats on Tuesday. Representative Katherine Clark is often tipped as a future member of the party’s congressional leadership and Seth Moulton, a former presidential candidate who easily won re-election, is just 41.
Most of the delegation had stayed clear of the race in the fourth district, except Ms. Pressley — who endorsed her former colleague and close confidant, Jesse Mermell. Ms. Mermell was the closest rival to Mr. Auchincloss, and earned the endorsements of progressive groups and leaders such as the Working Families Party and the Massachusetts attorney general, Maura Healey.
Because of the fractured field, supporters of Ms. Mermell had urged other candidates to leave the race before early voting began — hoping to consolidate the progressive wing and help her overtake Mr. Auchincloss.