Amy McGrath is the projected winner of Kentucky’s 6th Congressional District Democratic primary, a victory for the former Marine pilot that clears her path to run in the state’s only competitive general election.

The Associated Press called the race around 8 p.m.

McGrath appears to have bested Lexington Mayor Jim Gray in what would have been called an upset months ago. Many saw Gray, an experienced and popular politician from the district’s largest city, as the heavy favorite when he jumped in last year.

ADVERTISEMENT But the race tightened down the stretch as McGrath leaned on her personal story and her national donor base, as well as an emphasis on the rural counties not as familiar with Gray’s record.

McGrath burst onto the political scene last summer with a viral announcement video that told her story of becoming the first female Marine to fly an F/A-18 in combat. The video was passed around among top Democrats and played on the news, winning McGrath publicity and expanding her donor base.

But Gray shook up the race when he announced his bid in December. In doing so, he delighted top Democrats, including those at the Democratic Congressional Campaign Committee, who saw Gray as a top-flight candidate who would be sure to make the district competitive.

But instead of losing to the better-known candidate, McGrath stayed the course and chipped away at Gray’s lead.

At the end, Gray’s campaign launched a last-ditch move with the race’s only attack ad, which tarred McGrath as a carpetbagger for spending her career outside of the district. That attack drew criticism from McGrath and her allies, who argued that she left Kentucky to serve her country.

Despite the Democratic enthusiasm, Republicans are signaling they are ready for a fight. The Congressional Leadership Fund, the super PAC aligned with House leadership, has an office in the district that’s been mobilizing Republicans for months, and has booked $1.8 million in television advertising time in the district.