Something historic happened in Massachusetts on Tuesday night: A Kennedy lost an election. Seventy-four-year-old incumbent Senator Ed Markey beat out 39-year-old Representative Joseph Kennedy III in the state’s Democratic Senate primary. The outcome of the race flips the script on the upstart-insurgent-beats-Washington-old-timer formula that has been used by young progressives to great effect in recent election cycles.

The race stood out for another reason. Green groups are celebrating Markey’s win as a sign that climate change was a deciding factor in the election. In August of last year, Kennedy was up 17 points over Markey in one poll. He maintained an edge in the polls for the majority of the race. But Markey had a secret weapon, and Kennedy had a key vulnerability.

In 2019, Markey teamed up with New York Representative Alexandria Ocasio-Cortez — the quintessential upstart insurgent — to co-introduce a Green New Deal resolution that laid the groundwork for future legislation aimed at transitioning the United States off of fossil fuels in an equitable way. It attracted resounding support from an array of leaders and groups within the environmental and justice movements.

Introducing the Green New Deal turned out to be a superb political calculation for Markey, who tapped into that network of support in his time of need ahead of the primary this year. His campaign launched an ad featuring Ocasio-Cortez and secured endorsements from key environment groups like the Sierra Club and Environment America, which also backed him with financial donations. A survey in March showed that climate change was a top-tier issue for Democratic voters in the state’s primary election, second in importance only to health care.

Grist thanks its sponsors. Become one.

The Sunrise Movement, a youth climate group that works to get climate candidates elected across the country, claimed credit for Markey’s victory in a press release Wednesday. “Sunrise Movement helped Markey win the youth vote, win the internet, and define himself as the clear progressive choice in this race,” Varshini Prakash, co-founder and executive director of Sunrise Movement, said in a statement. “Perhaps just as significant, the visible and enthusiastic support from the youth of Sunrise made it nearly impossible for Kennedy to credibly position himself as the candidate of generational change.”

Kennedy’s vulnerability was the double-edged nature of his last name. As many pundits have pointed out, it was tricky for a member of the illustrious Kennedy clan to paint himself as a Washington outsider keen on shaking up the status quo. The Kennedys have been establishment Democrats for more than a century. To boot, Kennedy didn’t have a clear reason for challenging Markey, aside from perhaps advancing his political career by capitalizing on a seemingly vulnerable Senate seat. The two candidates’ views on a slew of issues align almost perfectly: Markey and Kennedy have lifetime voting scores of 94 percent and 96 percent, respectively, from the League of Conservation Voters. Kennedy was even a a co-sponsor of the Green New Deal resolution.

Grist thanks its sponsors. Become one.

Markey leaned hard on his climate bona fides to win the primary to draw a distinction between himself and his challenger, but so did Kennedy, whose age more neatly positioned him as a member of a climate movement that has become increasingly youthful in recent years. In the months before the primary, Kennedy met with climate activists fighting a natural gas compressor north of Boston and “crisscrossed Massachusetts to talk up environmental issues,” the Washington Post reported. In March of this year, Kennedy helped introduce an environmental justice bill in the House.

But Kennedy’s efforts to ingratiate himself with the climate movement couldn’t balance out Markey’s exceedingly long history of championing the environment in Congress, first as a representative for 36 years and then as a senator since 2013. During that time, he consistently voted for climate and environment bills and introduced a major piece of climate change legislation, the Waxman-Markey bill, which was passed by the House in 2009 and would have established a cap-and-trade system if it had been passed by the Senate.

With his seat secured, Markey now heads into a general election that he is almost sure to win.