U.S. Rep. Joe Kennedy III leaves the stage Tuesday after speaking outside his campaign headquarters in Watertown, Massachusetts. Credit: Charles Krupa / AP

Jake Auchincloss has won a packed primary to become the Democratic nominee in the race to fill the U.S. House seat being vacated by Rep. Joe Kennedy III in Massachusetts.

The Newton city councilor, a former Marine, edged out six other Democratic candidates in the crowded field for the open 4th Congressional District — a contest that took until early Friday to decide because of a deluge of mailed-in ballots that overwhelmed several cities and towns.

Nearly 1 million voters, skittish over the coronavirus pandemic, used the mail option for Tuesday’s primary. A state judge late Wednesday had approved a petition from Secretary of State Bill Galvin asking for more time for cities and towns to complete their vote tallies.

After graduating from Harvard College in 2010, Auchincloss served as a captain in the U.S. Marines. He commanded infantry in Afghanistan in 2012 and led an anti-narcotics platoon in Panama in 2014. He was elected to the Newton City Council in 2015. He also worked at a cybersecurity startup and as a senior manager at Liberty Mutual’s innovation lab.

Auchincloss, a moderate, was also briefly registered as a Republican in part of 2013 and 2014 while he worked to help elect GOP Gov. Charlie Baker — a background his primary rivals had publicly questioned.

He listed among his priorities making “health care a right, not a job perk,” protecting reproductive rights and combating the pollution that causes climate change. During the campaign, Auchincloss also said he wanted to help rebuild the country that sent his grandfather — “a poor Jewish kid” — to college during WWII.

Auchincloss narrowly defeated fellow Democrats Jesse Mermell, Becky Grossman, Alan Khazei, Natalia Linos, Isshane Leckey, Ben Sigel and Chris Zannetos.

State law allows campaigns to ask for recounts in specific precincts or city wards, and it wasn’t immediately clear if Mermell, a former aide to ex-Gov. Deval Patrick, would pursue that option. She had until Friday to decide, and Auchincloss held an unofficial 1,800-vote advantage, or just under 1.2 percent.

Kennedy opted not to seek reelection so he could challenge incumbent U.S. Sen. Edward Markey in the Senate Democratic primary, but lost that bid Tuesday, becoming the first member of the Kennedy political dynasty to lose a congressional race in Massachusetts.

Auchincloss will face Republican Julie Hall, an Air Force veteran who defeated David Rosa on the GOP ticket Tuesday, in the Nov. 3 general election for the right to represent the heavily Democratic district.

The district winds from the Boston suburbs of Newton and Brookline south through Attleboro, Taunton and Fall River.

The few other members of Massachusetts’ all-Democratic congressional delegation who had faced primary opponents — Reps. Richard Neal, Stephen Lynch and Seth Moulton — all breezed through Tuesday’s runoff.

Story by William J. Kole.