BOSTON — Stepping out of the rain on a dreary Saturday morning, Representative Joseph P. Kennedy III made no attempt to hide his frustration as he raced from neighborhood to neighborhood in a city as synonymous with his family as it is with the Green Monster.
Mr. Kennedy is trailing Senator Edward J. Markey in every poll ahead of the Senate primary on Tuesday, and may become the first Kennedy to lose a race in Massachusetts. He is struggling with idealistic young liberals and older, affluent white Democrats, the sort of voters who in an earlier era idolized his grandfather, Robert F. Kennedy, and his great-uncles.
Mr. Kennedy pointed to his strength with working-class Democrats and voters of color who are bearing the brunt of the coronavirus pandemic, all but scorning what he suggested was the hypocrisy of white liberals.
“For a progressive left that says that they care about these racial inequities, these structural inequities, economic inequities, health care inequities, the folks that are on the other side of that are overwhelmingly supporting me in this race,” he said. “Yet there seems to be a cognitive dissonance.”
It wasn’t supposed to be this way — at least not in the minds of Massachusetts Democrats, who have spent a lifetime watching a parade of Kennedys win elections against little opposition. When Mr. Kennedy first considered leaving his House seat last year to challenge Mr. Markey in a primary race, some in the party wondered if the 74-year-old incumbent would step aside for the 39-year-old political scion.
Instead, Mr. Markey, who was elected to the House before Mr. Kennedy was born, has harnessed the energy of the ascendant left and wielded his rival’s gilded legacy against him. And he has used his support from Representative Alexandria Ocasio-Cortez, whom he featured in an ad, and their joint authorship of the Green New Deal to establish himself as the clear front-runner.
That backing may help him avoid the fate of other longtime incumbents upended by young progressives, among them Representative William Lacy Clay of Missouri, who was defeated in a primary contest in August, and Joseph Crowley of New York, who was stunned by Ms. Ocasio-Cortez two years ago.
Mr. Markey’s strength illustrates the growing clout of progressives in the Democratic Party, particularly in states and districts that are heavily metropolitan and filled with well-educated voters. Each of the Democrats who have unseated incumbents in primaries in 2018 or this year did so in House seats anchored in cities or close-in suburbs, which is where most of the votes in Massachusetts can be found.
What’s so striking about the Senate race here, though, is that it’s the incumbent who framed himself as the bold insurgent.
Ms. Ocasio-Cortez’s endorsement provided the validation for that approach, Mr. Markey said.
“When she said, ‘It’s not your age but the age of your ideas,’ when she said that Ed Markey was the generational change that we have been waiting for, it helped to make clear that in this race I am the youngest guy because it’s about ideas,” Mr. Markey said, grinning through his Boston brogue.
The contest has grown ugly in the final weeks, as Mr. Kennedy has highlighted Mr. Markey’s history on racial justice issues and Mr. Markey has been urged to quiet supporters online who have made jokes about the assassinations of the congressman’s grandfather and his great-uncle, John F. Kennedy. It has also divided Democratic leaders in the state and in Washington, where Senator Chuck Schumer is supporting Mr. Markey while Speaker Nancy Pelosi is backing Mr. Kennedy.
The outcome of the race is not totally clear. Hundreds of thousands of people have already cast early ballots to avoid polling places because of the coronavirus outbreak, and supporters of both candidates agree that Mr. Kennedy’s prospects depend entirely on a primary-day surge of mostly nonwhite Democrats who vote more sporadically than those in Mr. Markey’s hyper-engaged base.
It won’t come easy, though: Mr. Markey was outspending Mr. Kennedy nearly four to one on commercials in the Boston market in the final week of the campaign.
That Mr. Markey has rebranded himself as an avatar of the millennial left is a cause of considerable wonder to longtime Massachusetts politicians, including some of his former colleagues.
“Markey has done a very skillful job of reinventing himself — as a politician I have admiration for the skill he’s done it with,” said former Representative Barney Frank, who served for decades with Mr. Markey and was succeeded by Mr. Kennedy but is supporting neither. “He was to Pelosi’s right.”
Less amused by Mr. Markey’s pivot is Mr. Kennedy. With undisguised exasperation, he rattles off his rival’s support for the 1990s-era crime bill, the Iraq war and the Patriot Act, and for his early-career opposition to the integration of Boston’s schools. “All of these votes are what the left has held Vice President Biden to account for,” he pointed out.
However, Joseph R. Biden Jr., the Democratic nominee, benefited in the presidential primary race from a more pragmatic electorate that was fixated on defeating President Trump.
Mr. Markey, conversely, has been able to forge a coalition that includes a number of onetime supporters of Senators Elizabeth Warren of Massachusetts and Bernie Sanders of Vermont, who together won over 48 percent of the vote in Massachusetts’s multicandidate presidential primary this year.
Also crucial to Mr. Markey, who joined the Senate after John F. Kerry left the seat to become secretary of state in 2013, has been a successful digital operation. His staff used the work-from-home months, when most voters were glued to screens, to cast him as something of a unintentional hipster who still wears chunky 1989 Nike Air Revolutions.
It is one of the few areas where Mr. Kennedy and Mr. Markey agree — the incumbent’s ability to link the very online left with local Democratic officials who swear by incumbency.
“We’ve taken the established leaders and partnered them with the digerati,” Mr. Markey said in an interview in Brockton, Mass., where he held an outdoor rally just steps away from the statue of the hometown hero Rocky Marciano.
Back in Boston, Mr. Kennedy said much the same.
“There was a combination of an insurgent left supporting the senator and a more establishment left that doesn’t like primaries, where he was able to kind of unify them both,” he said of his opponent.
Mr. Kennedy, to the dismay of some of his supporters, was reluctant to embrace his family legacy for much of the campaign. He eschewed the barely veiled appeals of his predecessors, like former Senator Edward M. Kennedy, who boasted of his connections during his first Senate campaign with the slogan “He Can Do More for Massachusetts.”
Only after Mr. Markey made a few unmistakable references to the Kennedys — including in an ad that concluded “With all due respect, it’s time to start asking what your country can do for you” — did the congressman give a speech and air commercials invoking his relatives.
Those appeals, however, do little to sway Mr. Markey’s young admirers, many of whom were not even eligible to vote the last time a Kennedy ran statewide here, in 2006.
“He’s trying to ride this progressive wave, the young progressives that are upending older candidates,” said Molly Ohman, 27, who came to cheer on Mr. Markey in Brockton and deemed the Kennedy challenge “ageism.”
For his part, Mr. Markey steadfastly avoids mentioning his opponent’s name. When he’s asked about the Kennedy family legacy, he invariably invokes his own blue-collar roots as the son of a milk truck driver, “a Markey from Malden,” drawing the contrast implicitly if not subtly.
This appeal helps reinforce one of Mr. Kennedy’s most significant weaknesses in today’s Democratic electorate — the perception that he’s the candidate of privilege.
“It turns out being named Joe Kennedy is a mixed blessing,” Mr. Frank quipped.
Of course, many of the voters most likely to be moved by contempt for privilege tend to be more upscale themselves, while polls indicate that Mr. Kennedy is embraced by many working-class voters — white and nonwhite — who haven’t thumbed through “White Fragility.”
In a recognition of this searing moment of reckoning over race, and his need to respond to Mr. Kennedy’s attacks on his record on issues like school integration and the crime bill, Mr. Markey has infused his closing stump speech with tributes to the Rev. Dr. Martin Luther King Jr., a call for reparations and praise for the athletes protesting police brutality.
“Democracy is not shared as long as Black and brown men continue to get shot, injured or murdered in the streets by police officers supposed to protect them,” he said in Brockton, lamenting what he called “a criminal injustice system.”
Mr. Markey has also reoriented his schedule in the campaign’s closing days to more aggressively target voters of color.
On Saturday, he stood in a diverse Boston enclave before a group of Black ministers and one of his most prominent Black supporters: the Suffolk County district attorney, Rachael Rollins.
Ms. Rollins acknowledged after the event that the Kennedy name still resonated with many voters of color, and said she wished Mr. Markey had done more to appeal to minority voters.
“We can be messaging better,” she said.
But she called Mr. Kennedy’s challenge “selfish” and suggested he was running now only to avoid a future Senate primary race against Representative Ayanna Pressley, who unseated a longtime Democratic incumbent two years ago. “I’d be shocked if Ayanna didn’t jump,” Ms. Rollins said of Ms. Pressley’s Senate ambitions.
As he hunted for votes in Boston, Mr. Kennedy found his most enthusiastic support from Black voters and older whites with memories of his forebears.
“The Kennedys have a legacy here, they’ve been good to Massachusetts,” said Patricia McCormack, 69, whose first husband was the nephew of the former Speaker John W. McCormack, another Massachusetts legend.
Mr. Kennedy was viewed just as warmly as he rallied union supporters in Dorchester, where black and white images on a wall inside the I.B.E.W. hall include a picketer in a hard hat wearing a “Kennedy” T-shirt.
Perhaps more revealing was the polite but largely unenthusiastic reaction he got in South Boston, the historically Irish neighborhood that has become increasingly gentrified. As he strode around the cafes and brunch spots that now dot Whitey Bulger’s old neighborhood, many of the younger voters were noncommittal.
Jose Luna, a 26-year-old immigration lawyer who went to Boston College with a Kennedy cousin, was one of the few millennials who approached him for a selfie.
But as he walked away, Mr. Luna declined to say whom he was supporting. “I’ll be voting,” he said. “I’m just not going to talk about it.”