After nearly half a century in Congress, Sen. Ed Markey, D-Mass., was expecting the primary race of his life against Rep. Joe Kennedy III, the young and telegenic standard-bearer for the legendary political clan who announced his challenge with a message of urgency in September 2019.
Almost a year later, Markey, 74, heads into election day as the front-runner -- touting his alliance with Rep. Alexandria Ocasio-Cortez, D-N.Y., and his working-class roots to cast himself as the anti-establishment choice in the race against Robert Kennedy's grandson.
"Markey has done a very good job of, in some ways, reinventing himself and turning this around so he's more the insurgent," former Rep. Barney Frank, a Massachusetts Democrat who has remained neutral in the primary, told ABC News.
The race -- which has divided Democrats in Washington and tested the durability of the Kennedy brand in Massachusetts -- could be the first election a member of the family has ever lost in the state.
Markey aligned with progressive leaders
Unlike some long-serving incumbents who have recently lost primaries to dynamic, younger Democrats running from their left, Markey, who was first elected to Congress before Kennedy was born, closely aligned himself with leading progressives.
That includes Suffolk County District Attorney Rachael Rollins, Ocasio-Cortez and Sen. Elizabeth Warren, D-Mass., who endorsed Markey before Kennedy -- her former Harvard Law School student -- announced his bid.
In an interview with ABC News from his campaign bus, Markey recalled inviting Ocasio-Cortez to lunch in the Senate dining room in Washington after her surprise 2018 primary victory in New York -- a meeting that lasted two-and-a-half hours and formed the basis for their partnership on the Green New Deal, the signature environmental plan he introduced in the Senate.
"I am the candidate of change in this race, as Alexandria Ocasio-Cortez has been saying," Markey told ABC News, one of the roughly half-a-dozen times he mentioned the New York Democrat in the fifteen-minute interview.
Markey, whose campaign has also released a 30-second spot featuring Ocasio-Cortez speaking straight to camera, recently released a longer-form video about his career, blending elements of his personal biography -- his working-class roots as the son of a milkman from Malden, Massachusetts -- with scenes from recent Black Lives Matter and climate change protests.
"With all due respect, it's time to start asking what your country can do for you," Markey said in the now-viral video, produced by the Sunrise Movement, a youth-led environmental group that helped push the Green New Deal, and endorsed Sen. Bernie Sanders in the Democratic presidential primary.
The tongue-in-cheek riff on President John F. Kennedy's famous line is one of several times Markey has subtly referenced Kennedy's family in an effort to sharpen the contrast between the two candidates' backgrounds.
In their last debate, Markey took Kennedy to task over reports that his father, former Rep. Joe Kennedy II, was funding a Super PAC attacking the senator.
"Tell your father you don't want the money to be spent on negative ads," Markey said, as Kennedy noted that he had come out against negative advertising publicly and repeatedly.
Kennedy embraces family legacy in final stretch
Until Markey's jabs at his family in their last debate, Kennedy, 39, spent most of the primary downplaying his lineage on the trail.
The name is a "mixed blessing," Frank told ABC News, "in the current climate of almost reflexive anti-establishment-ism, even among people on the left."
"You get me, you're not getting my father and you're not getting my grandfather, either of his brothers or anybody else. You get me for better or worse," Kennedy said in a phone interview on Saturday between campaign stops in Lowell and Worcester, two of Massachusetts' largest cities that were once industrial centers.
In the closing days of the race, Kennedy deployed family members as surrogates, including Vicki Kennedy, the wife of the late Sen. Ted Kennedy, and family matriarch Ethel Kennedy, his grandmother.
The call to the Kennedy family cavalry is the latest shift in a campaign that has struggled to articulate a clear rationale, Democrats and experts said.
Seen as the favorite when he entered the race last year -- so much so that some Democrats speculated his announcement would lead to Markey to consider retiring - Kennedy instead finds himself running as the underdog, and barnstormed the state for 40 events in the last four days of the race to scrounge up votes from any remaining undecided Democrats.
The role reversal is even more surprising given the relative lack of policy disagreements between the two candidates.
Markey and Kennedy "are ideological peas in the same pod," said Jeffrey Berry, a professor of political science at Tufts University. "They have some different priorities -- Markey on the environment, most notably, and Kennedy on civil rights and mental health. But if they served in the Senate together for the next six years, they would have almost identical voting records."
Only in the race's final weeks has Kennedy sought to define Markey, sharpening his attacks over Markey spending the least amount of time in the state of the entire Massachusetts delegation. He's also focused on the aspects of Markey's long record that conflict with contemporary progressive positions, such as his 2002 vote in favor of the Iraq War, his backing of the 1994 crime bill and his opposition to busing in the 1970s to achieve racial desegregation in Boston public schools.
Markey has distanced himself from some of his more conservative stances in the 1980s and called his vote for the war in Iraq a mistake.
Just ahead of Tuesday, the congressman made perhaps his most coherent argument against Markey, calling out his effectiveness and suggesting that he isn't a progressive who can get things done.
"Just because you file the bill doesn't mean it passes and … Mitch McConnell and Donald Trump certainly aren't going to support sweeping legislation," he told ABC News in an apparent swipe at Markey for his role in the Green New Deal. "Success is never final in this business, failure isn't either. But it means that just because you get a law passed, you still have to approach this with the relentlessness that this moment demands."
It's not clear how effective Kennedy's closing efforts to define Markey will be in the race. The senator, who was largely unknown statewide before this campaign, used a strong digital operation to successfully rebrand himself into a favorite of young progressives, who have helped his ads go viral online and spread dozens of Markey-themed memes.
"In the absence of a compelling narrative from Joe Kennedy, Ed Markey was able to sort of define himself and really I think set the tone for the campaign that Kennedy wasn't ever able to, I think, really effectively counter," said Shannon Jenkins, a professor of political science at the University of Massachusetts Dartmouth.
The other key race in the Bay state
Markey isn't the only incumbent facing a tough primary challenge on Tuesday.
Rep. Richard Neal, 71, the chairman of the powerful House Ways and Means Committee, is facing progressive Holyoke Mayor Alex Morse, who earned the backing of Ocasio-Cortez's Courage to Change PAC and Justice Democrats.
In what has been a bitter primary for the 1st Congressional District, which covers most of western Massachusetts, Neal is defending his seat after College Democrats at the University of Massachusetts-Amherst, who are supporting the veteran congressman, reportedly engineered allegations of impropriety against Morse.
Morse, who was elected at 22, denied using his position as mayor and as a lecturer at U-Mass Amherst to pressure students into relationships, though he acknowledged having consensual relationships with college students. Neal and his campaign have denied knowledge of the effort against Morse.