BOSTON (AP) — Boston City Councilor Ayanna Pressley stunned fellow Democrats by defeating incumbent U.S. Rep. Michael Capuano in a closely watched Massachusetts primary battle Tuesday.

Pressley is virtually assured of becoming the first black woman elected to Congress from Massachusetts in November, and her victory gives Democrats' progressive wing another win in their effort to pull the party leftward.

There are no Republican candidates running for the seat.

Pressley told her supporters her win was a shot across the bow not only of establishment politics but of the Democratic Party itself and demonstrated a desire for governing that is "bold, uncompromising and unafraid."

"With our rights under assault, with our freedoms under siege," Pressley said, "it isn't good enough to see Democrats back in power, but it matters who those Democrats are."

Results of Massachusetts’ 7th Congressional District Democratic primary.

Pressley, who labeled President Donald Trump racist and misogynistic, said she knew when she launched her campaign that she "would find no favor with the Democratic establishment both here at home and in Washington."

"But change can't wait," she added.

Capuano is the second Democrat and fourth House incumbent to lose a primary ahead of the November midterms. During the campaign Pressley had drawn comparisons to Alexandria Ocasio-Cortez, who ousted 10-term New York Rep. Joe Crowley in a Democratic primary in June.

Capuano told supporters he did everything he could to win re-election.

"Apparently the district just is very upset with lots of things that are going on. I don't blame them. I'm just as upset as they are, but so be it," Capuano told supporters. "I'm sorry it didn't work out, but this is life. And this is OK. America's going to be OK. Ayanna Pressley is going to be a good congresswoman and I will tell you that Massachusetts will be well-served."

The race drew national attention because it was seen by some as a possible indication of deeper generational and philosophical shifts within the Democratic Party, led by younger candidates who take more liberal positions on issues ranging from universal health care to immigration enforcement.

When Massachusetts lawmakers drew new House districts after the last federal census, they tapped the 7th District to be the first in Massachusetts where minorities make up a majority of the voting population.

During the campaign, the 44-year-old Pressley acknowledged she would likely vote the same way as Capuano on most issues, but argued she would be a different kind of political leader for the district and the state.

The 66-year-old Capuano, who is white, said he always worked on behalf of everyone in the district, which includes parts of Boston, Cambridge, Somerville and other communities. A former Somerville mayor, Capuano relied in part on voters who have supported him for decades while also trying to reach out to newer voters.

Both candidates also banked on deep voter anger with Trump.

In other House races:

— In the state's 1st district, Rep. Richard Neal defeated Democratic primary challenger Tahirah Amatul-Wadud, who had hoped to become the first Muslim elected to Congress from Massachusetts. Neal will run unopposed in November.

— In the 9th district, Democratic incumbent Rep. Bill Keating defeated primary challenger William Cimbrelo. Keating will face Republican Peter Tedeschi in November.

— In the 4th district, Democratic Rep. Joe Kennedy defeated primary challenger Gary Rucinski and will run unopposed in November.

— In the 8th district, Incumbent Democratic Rep. Stephen Lynch defeated two primary challengers, including Boston-based software engineer Brianna Wu. There are no Republicans running.

— Republican Tracy Lovvorn won the GOP primary to face Democratic Rep. Jim McGovern in the state's 2nd district.

— Republican John Hugo will face Democratic Rep. Katherine Clark in November in 5th district.

— Ten Democrats were competing in the 3rd district primary to fill the seat left open by Democratic Rep. Niki Tsongas, who is retiring.