BOSTON — Ayanna Pressley is all but assured of becoming the first black woman elected to Congress from Massachusetts, the latest example of the Democratic Party’s embrace of diversity and progressive politics as the recipe for success in the Trump era.

The 44-year-old’s upset victory against longtime Democratic Rep. Michael Capuano in Tuesday’s primary sets the stage for Pressley to represent an area once served by Tip O’Neill and John F. Kennedy. Her win comes at the tail end of a primary season in which black politicians have made a series of advances.

In nearby Connecticut, Jahana Hayes is on track to become that state’s first black woman to win a congressional seat if she prevails in November. And black politicians in three states — Florida, Georgia and Maryland — have won the Democratic nomination for governor, a historic turn for a country that has elected just two black governors in U.S. history.

Greeting voters at a Boston polling station, Pressley spoke of “the ground shifting beneath our feet and the wind at our backs.”

“This is a fight for the soul of our party and the future of our democracy,” she told reporters. “This is a disruptive candidacy, a grassroots coalition. It is broad and diverse and deep. People of every walk of life.”

For Pressley, as with many other ascendant candidates of color, unabashedly progressive credentials smoothed her path to victory in the primary. No Republicans were running, so only a write-in campaign in November could possibly stand between her and Washington.

She was endorsed by fellow congressional upstart Alexandria Ocasio-Cortez, who knocked off veteran Rep. Joe Crowley of New York in June. Pressley backs Medicare-for-all, the single-payer healthcare proposal, which helped her garner backing from Our Revolution, the offshoot of Vermont Sen. Bernie Sanders’ 2016 presidential campaign.

Pressley called for defunding the federal Immigration and Customs Enforcement agency, known as ICE, which helped her draw support from Massachusetts’ popular attorney general, Maura Healey, who’s gained a national following for repeatedly suing President Donald Trump in an attempt to block his policies on immigration, gun control and other issues.

“We have to be disruptive in our democracy and our policymaking and how we run and win elections,” she said in an interview this summer with The Associated Press, adding that Ocasio-Cortez’s victory challenged “narratives about who has a right to run and when, and who can win” in American politics.

“My mother did not raise me to ask for permission to lead,” she added.

Pressley tapped into growing cries within the Democratic Party for newer, more diverse leadership. She and Ocasio-Cortez both defeated older, white congressmen who were reliable liberal votes, but who didn’t look like many voters in their districts.

The district she’s competing in includes a wide swath of Boston and about half of Cambridge as well as portions of neighboring Chelsea, Everett, Randolph, Somerville and Milton. It includes both Cambridge’s Kendall Square — development there is booming — and the neighborhood of Roxbury, the center of Boston’s traditionally black community.

Pressley has bristled at the notion that race was a defining issue in her campaign.

“I have been really furious about the constant charges being lobbed against me about identity politics that, by the way, are only lobbed against women and candidates of color,” she said in one debate. “I happen to be black and a woman and unapologetically proud to be both, but that is not the totality of my identity.”

Massachusetts’ last Democratic primary upset came in 2014, when Seth Moulton defeated Rep. John Tierney in the state’s 6th Congressional District.

Associated Press writers William J. Kole in Boston and Bill Barrow in Atlanta contributed to this report.