ST. PAUL — Doug Wardlow was a little-known former state representative 18 months ago when he announced what appeared to be a long-shot candidacy to be Minnesota’s next attorney general.

It was a daunting challenge. No Republican has been elected as Minnesota’s top lawyer in two generations, since 1966. And this summer, after Minnesota’s incumbent attorney general pivoted to run instead for governor, Mr. Wardlow remained overshadowed by a powerful new opponent with high name recognition, Representative Keith Ellison, a vice chair of the Democratic National Committee and the first Muslim elected to Congress.

But in recent weeks, Mr. Wardlow has received one of the biggest political gifts of the midterm election cycle, in large part because of his opponent’s fall from grace, after Mr. Ellison’s former girlfriend said that he mistreated her. The charges, which Mr. Ellison denies, have snapped voters to attention across the state.

The race has shifted dramatically in Mr. Wardlow’s favor. Last month, Mr. Ellison had a five-point lead among likely voters, according to a Star Tribune/Minnesota Public Radio News poll. But the numbers have more than flipped: Mr. Wardlow has taken a seven-point lead, according to the group’s new poll taken last week.