Former Marine pilot Amy McGrath defeated her progressive opponent Charles Booker in the Kentucky primary, setting up a high-profile showdown between her and Senate Majority Leader Mitch McConnell in November, the Associated Press projected Tuesday.

Ten candidates in total ran in the Democratic primary. McGrath had been the most high-profile candidate, but Booker surged into contention with endorsements from progressive icons Sens. Bernie Sanders of Vermont and Elizabeth Warren of Massachusetts, and first-term Rep. Alexandria Ocasio-Cortez of New York.

Booker embraced progressive ideas such as universal basic income and Medicare-for-All, while McGrath resisted doing so.

The surge by Booker, who is black, came amid a time of nationwide protests over police brutality against minorities and systemic racism.

MCCONNELL IN NEW AD HITS OPPONENT AMY MCGRATH FOR SUPPORTING TRUMP IMPEACHMENT, CALLS HER 'EXTREME'

Voting ended June 23, but it took a week until McGrath could be declared the winner due to the race’s tight margins and a deluge of mail-in ballots. McGrath’s win seemed a certainty early in her campaign, but Booker’s profile rose as he highlighted protests against the deaths of African Americans in encounters with law enforcement.

It was a narrow victory for McGrath. The Associated Press declared her the winner with 89 percent of precincts reporting Tuesday afternoon, where she had a nearly 9,500-vote advantage over Booker.

Since McGrath entered the race, she and McConnell have gone toe-to-toe in attack ad campaigns.

DEM ESTABLISHMENT FAVORITE MCGRATH FACES LAST MINUTE PRIMARY CHALLENGE FROM THE LEFT 

In the day following the close of Kentucky polls, McConnell earned $1 million in donations. McGrath, backed by the Democratic establishment, had raked in over $40 million by the start of June, leveling the playing field between her and always-well-funded McConnell.

Still, she faces an uphill battle in the state that President Trump led by about 30 points in 2016.

Booker’s longshot Senate bid gained attention when he marched alongside protesters in his hometown of Louisville to demand justice for Breonna Taylor, a black woman shot in her home by police after they executed a no-knock warrant on the wrong house. Still, McGrath had a massive cash advantage over Booker.

CLICK HERE TO GET THE FOX NEWS APP

McGrath accuses McConnell of spending too much time on tax cuts for the wealthy and not enough time on affordable health care, hitting his vote to repeal the Affordable Care Act. McConnell’s campaign has said McGrath is too liberal for Kentucky, on issues from abortion to border security.

Fox News' Ronn Blitzer and The Associated Press contributed to this report.