U.S. Sen. Edward Markey of Massachusetts defeated U.S. Rep. Joe Kennedy III in Tuesday’s hard-fought Democratic primary, harnessing support from progressive leaders to overcome a challenge from a younger rival who is a member of America’s most famous political family.

It was the first time a Kennedy has lost a race for Congress in Massachusetts.

Markey appealed to voters in the deeply Democratic state by positioning himself as aligned with the liberal wing of the party. He teamed up with a leading progressive, New York Rep. Alexandria Ocasio-Cortez, on the Green New Deal climate change initiative, and at one point labeled Kennedy “a progressive in name only.”

That helped Markey overcome the enduring power of the Kennedy name in Massachusetts. The 39-year-old congressman sought to cast the 74-year-old Markey as someone out of touch after spending decades in Congress, first in the House before moving to the Senate.

At a victory celebration in his hometown of Malden, Massachusetts, Markey ticked off a series of priorities, from support for the Black Lives Matter movement to a call for Medicare for All, to combating climate change, a signature issue for Markey.

“Every other problem is linked to it. No solution to any challenge will be successful unless we address it. There will be no peace, no justice and no prosperity unless we stop the march to climate destruction,” he said. “We must pass a Green New Deal.”

To make good on those pledges, Markey said Democrats have to take back control of the U.S. Senate and oust President Donald Trump in November.

“He is the most corrupt, most racist, most incompetent president in American history,” Markey said. “We must banish his agenda of division and destruction to the history books.”

In perhaps the most important speech of his political career, President Donald Trump said the upcoming election is the nation’s most important in history.

Markey also credited his win in part to support from younger voters telling them “when they say you’re too young, show up with your friends.”

Earlier Tuesday evening Kennedy said that while the results aren’t the ones he’d hoped for, he would work for Markey’s reelection.

“The senator is a good man. You never heard me say otherwise,” Kennedy told supporters at an outdoor rally. Kennedy also suggested that the movement of supporters the campaign pulled together would continue past the current election.

“We may have lost the final vote count tonight but we built a coalition that will endure,” he said. “I would do this again with all of you in a heartbeat.”

In the waning weeks of the campaign, Kennedy leaned into his family’s long political legacy in Massachusetts. His pedigree includes former President John F. Kennedy; former U.S. Senator and U.S. Attorney General Robert F. Kennedy, his grandfather; and former U.S. Sen. Edward Kennedy, who held a Senate seat in Massachusetts for nearly half a century until his death in 2009.

The Family of Robert Kennedy

Markey countered by leaning into his own family story — growing up in the working class city of Malden with a father who drove a truck for the Hood Milk company.

In one campaign video, Markey also paraphrased a famous JFK quote, saying, “We asked what we could do for our country. We went out, we did it. With all due respect, it’s time to start asking what your country can do for you.”

Markey found himself on the defense at times during the campaign, with Kennedy repeatedly trying to portray him as having a tin ear to racial equity concerns.

Kennedy faulted Markey for his initial opposition to the effort to desegregate the Boston Public Schools beginning in the 1970s.

Markey countered by noting that he changed his views on the contentious issue that tore at the fabric of the city. He also said he supported the creation in 1973 of a state Senate seat aimed at helping elect a Black senator to the Massachusetts Legislature.

Kennedy also repeatedly pointed to the father of Danroy “DJ” Henry, a young Black man from Massachusetts killed by police 10 years ago. Henry’s father has criticized Markey, saying he failed to help the family seek justice.

Markey said he has apologized to the Henry family and signed a letter seeking a federal Justice Department investigation into the killing.

Markey also wasn’t shy about talking about the Kennedy family, at one point pressing Kennedy to tell his father — former U.S. Rep. Joe Kennedy ll — to stop supporting a political action committee that was running ads against Markey.

“I’m sure your father is watching right now,” Markey said. “Tell your father right now that you don’t want money to go into a super PAC that runs negative ads.”

Kennedy said he had “no idea” if his father was helping fund the PAC.

Remembering John F Kennedy

Late in the race, Kennedy landed a major endorsement when Democratic House Speaker Nancy Pelosi formally backed his candidacy.

While Markey, who served with Pelosi in the House for decades, congratulated Kennedy, Pelosi’s decision angered some of Markey’s younger progressive supporters. Markey had earlier won the endorsement of Ocasio-Cortez and fellow Massachusetts Democratic U.S. Sen. Elizabeth Warren.

The coronavirus upended the way both candidates could campaign — limiting more traditional means of electioneering like knocking on doors, shaking hands or holding big rallies.

Instead, the campaigns were largely waged online with virtual rallies, virtual endorsements, virtual fundraisers and virtual roundtable events to discuss issues. Eventually, as Massachusetts began to suppress the virus and emerge from a near lockdown, the candidates began to take their campaigns on the road with social distancing and face masks.

The showdown drew criticism from some Democrats nationally who feared it would siphon time and money away from defeating President Donald Trump and winning control of the Senate. It also wasn’t cheap, with both Kennedy and Markey raising and spending millions.

Markey now faces a general election contest where he is considered a strong favorite against Republican primary winner, Kevin O’Connor, in November.