BRIGANTINE, N.J. — Amy Kennedy is an unlikely heir to a family dynasty that first set foot in Congress in 1947 and has won the White House, sent three men to the Senate and propelled several members into the House.

Kennedy, 41, grew up in this Jersey Shore outpost in a family that was politically active only at the municipal level. She spent 10 years as a public school teacher.

Now, the mother of five is running in a key congressional battleground that has the backdrop of President Trump and a Democratic vendetta to take out a once trusted ally who betrayed them.

And, in perhaps the most unusual fashion, she is running as an outsider, trying to establish a new beachhead for one of the most famous families in Democratic politics.

“It’s not the name, it’s more people just associate that legacy with kind of the unfinished work of social justice. And that’s what I think people are really hungry for right now,” Kennedy said Wednesday in an hour-long interview at her house on the bay.

The irony is not lost on Kennedy’s main opponent, who has spent 20 years as a political commentator in New Jersey, a tenure that helped to quickly win the backing of six of the eight Democratic county chairmen in this district.

“The Kennedys as outsiders,” Brigid Callahan Harrison said Wednesday, in an hour-long telephone interview, amazed at how much the race is pivoting on personality. “That is how they’re marketing this.”

So, as voters check off their mail ballots in this pandemic-era July 7 primary election, the battle is coming down to two powerful, yet very different political machines: the Kennedys versus South Jersey power brokers.

Neither Kennedy nor Harrison is really supposed to be running for this seat.

For Kennedy, her destiny flipped after a chance meeting in 2010 at an Atlantic City conference on mental health, with then-Rep. Patrick J. Kennedy (D-R.I.) headlining. He was winding down the last months of a 16-year career in Congress, one that had seen plenty of public battles with substance abuse. His family’s history with mental illness had made that the central cause of his public service.

A few months before his father, Edward M. Kennedy (D-Mass.), a legendary senator of almost 47 years, lost his fight with brain cancer.

By July 2011 Patrick and Amy married at Hyannisport, the family compound on Cape Cod where so many Kennedy campaigns had been mapped out. But instead of settling in New England, he moved about 400 miles down the coast to Brigantine, leaving behind the family business.

Harrison, after losing a local municipal race in the late 1990s, was hired as a political science professor at Montclair State University. She did commentary on local TV and wrote a regular column in some New Jersey papers, always engaged in policy without ever fully entering the arena herself.

In 2018, Democratic women, many running for the first time, racked up wins and handed the gavel back to House Speaker Nancy Pelosi (D-Calif.), while South Jersey Democrats supported a socially conservative white man: Jeff Van Drew, who had climbed his way up the ladder of state politics in Trenton.

“I held my nose and voted for him,” Harrison, 55, said.

Then came Van Drew’s vote on Halloween to oppose Pelosi’s move toward impeaching the president over the Ukraine scandal.

“I was sick to my stomach,” Harrison recalled.

So she began floating her name as a potential primary opponent. She talked to party operatives and, having never really raised campaign funds, asked Patrick Kennedy if he would join her finance team if she went through with it.

Van Drew did not just oppose impeachment — he switched parties and, in the Oval Office, shook Trump’s hand and pledged his loyalty. Amy Kennedy felt sick to her stomach.

“How is that possible? And kind of knowing the significance there, and what that meant for this upcoming election, how it would then become a race about Trump really — that felt like the moment,” she said.

By the time she entered the race, Harrison had already locked down much of the establishment support.

So Harrison, who began as an insurgent challenging a favorite Democratic son, has become the establishment pick, including an unusual alignment with Sen. Cory Booker (D-N.J.) so that their names are bracketed together on the primary ballots.

Kennedy, with a last name that is synonymous with Democratic power, is now running as the outsider in a district that she has lived and worked in her entire life.

What has ensued is an increasingly bitter, personal campaign that is befitting of this state’s bare-knuckle traditions.

Moreover, with Gov. Phil Murphy (D) endorsing Kennedy, New Jersey’s intensely myopic insider class has lost focus on defeating Van Drew and instead see this primary as a proxy fight in a long-running civil war.

Murphy has clashed with Democratic power broker George Norcross and his protege, state Senate President Stephen Sweeney (D), from almost his first day in office in January 2018. Norcross, a private businessman, does not technically hold an official party position but his influence resembles a character from the HBO show “Boardwalk Empire,” about Atlantic City during Prohibition.

Kennedy is trying to overcome that influence with a mix of hometown tied to an incredible legacy. Her Brigantine home is filled with family memorabilia, including a framed box of all the airline tickets that Patrick Kennedy collected as he traveled across the country in 2000 as chairman of the Democratic Congressional Campaign Committee.

She is viewed fondly by her extended family, someone who helped anchor Patrick Kennedy’s life. They have four children together, and he is a doting stepfather to her eldest daughter.

“She’s fantastic,” Rep. Joe Kennedy (D-Mass.) said.

Joe Kennedy laughed at the idea of his cousin by marriage running as an outsider, as he is in the midst of a challenge to Sen. Edward J. Markey (D-Mass.).

The coronavirus pandemic has limited how much in-person campaigning the Kennedys can do, but the family is helping where it can. Joe Kennedy did a Facebook Live chat with Amy Kennedy.

A piece of mail includes images of John F. Kennedy as president and his son saluting his casket at his funeral after the 1963 assassination, among other iconic pictures.

“Ask not what your country can do for you,” it says, “ask what Amy Kennedy can do for your country.”

All of this has pushed Harrison to complain that her opponent is running “exclusively on the fact that she married someone with a famous last name.”

The two largely agree on policy, but Harrison stresses, “I know policy, so there’s a big difference. I’m a candidate of substance.”

Kennedy dismisses those attacks as academic elitism, incapable of connecting with typical voters. “To really connect with people, that’s more about the personal stories that they have,” she said.

A victory here, in the primary and over Van Drew, would demonstrate the Kennedy name still resonates.

“There’s that unfinished business,” Kennedy said, “that sense of unfinished business.”

Correction: An earlier version of this column misidentified New Jersey Senate President Stephen Sweeney as John. This story has been updated.