Minnesota state House Speaker Lisa Demuth won the Republican primary for governor, NBC News projects, defeating Trump ally Mike Lindell and setting up a general election matchup against Democratic Sen. Amy Klobuchar.

Demuth’s victory was an upset over Lindell, the MyPillow founder and election conspiracy theorist. Lindell had been leading in limited public polling heading into Election Day, and President Donald Trump endorsed him.

But attacks on Lindell from fellow Republicans — including questions about his residency raised by the chairman of the Minnesota Republican Party — hampered his campaign in the final weeks before the primary, as members of the Minnesota GOP sought a nominee who could beat Klobuchar in the general election.

Lindell has faced several legal challenges since 2020, when he championed Trump’s debunked theories about the 2020 presidential election, which former President Joe Biden won.

At a Minnesota Farmfest forum this month, Klobuchar appeared alongside three GOP candidates for governor and accused each of them of being “a rubber stamp of Donald Trump.”

Demuth and other Republicans — including Trump — have attacked Democrats in the blue state over two sprawling fraud scandals involving Medicaid and pandemic aid. Among the allegations were that hundreds of millions of dollars that had been earmarked for welfare programs were stolen.

At the farm event, Demuth blamed “incompetent Democrat control” for the fraud cases, and she has pointed on the campaign trail to the Fraud Prevention Agency Oversight Committee, which she established leading the state House.

In January, Democratic Gov. Tim Walz, who had planned to run for a third term, decided to drop his re-election campaign, citing the attacks over the fraud cases. A few weeks later, Klobuchar launched her campaign. She is one of four senators to run for governor this year.

Still, Republicans will have to overcome political trends in Minnesota in November to win the Governor’s Residence. Then-Vice President Kamala Harris won the state by about 4 percentage points in the most recent presidential election, when Walz was her running mate.