RICHMOND, Ky. — People have been telling Amy McGrath “no” for a long time.

No, you cannot compete against the boys in sports. No, you cannot serve in combat or fly fighter jets. And no, you certainly cannot defeat the popular mayor of the largest city in your congressional district as a first-time candidate.

A wall of trophies, a degree from the Naval Academy, 89 combat flight missions and one stunning House Democratic primary victory later, Ms. McGrath is growing more used to the sound of “yes,” even as she moves to turn around the toughest “no’s” yet, Republican voters in the suddenly bellwether Sixth Congressional District of Kentucky.

On Tuesday, she easily defeated Jim Gray, the well-liked mayor of Lexington, for the Democratic nomination in Kentucky’s Sixth. Republicans moved immediately to define her as the far-left candidate who triumphed despite a rejection by the Democratic establishment. But Democrats united around her just as quickly, turning the fight this summer and fall for Kentucky’s Sixth into a critical test of the Democrats’ vaunted “blue wave.”

The story of how Ms. McGrath became an avatar for that wave is a narrative that combined a compelling biography, risk-taking, the virtues of the digital age and the willingness to compete even when party elders in Washington were trying to stop her. She slogged through a grueling climb in the polls, suffered a personal tragedy just last month, then fended off a late and unexpected negative attack — all for the chance to compete against an incumbent Republican, Representative Andy Barr, who won his last re-election race by 22 percentage points.