Democratic state Sen. Laura Kelly has won the Kansas governor’s race, defeating Kansas secretary of state and Donald Trump ally Kris Kobach.

Kansans chose to elect a Democratic governor just two years after supporting Trump by over 20 percentage points. Polls showed a tied race heading into Election Day, but Kelly ended up with a fundraising edge over Kobach, a controversial figure with a national profile.

While Kansas is frequently thought of as a deep-red state, former Gov. Sam Brownback (R) left office this year as one of the least popular governors in the country. He resigned to take a job in the Trump administration. Polls also showed that a large number of voters in the state had a negative view of Kobach, who had risen to prominence as a conservative hard-liner on voting restrictions and immigration.

ASSOCIATED PRESS

Despite Kobach’s rising star in the GOP, two Republican former governors and a former U.S. senator for Kansas endorsed Kelly. Among his more controversial proposals, Kobach had vowed to reimplement Brownback’s steep tax cuts, which were so disastrous for the state’s economy that Republicans repealed them. Kelly’s campaign consistently sought to tie Kobach to Brownback.

Kelly’s win is also a defeat for Trump, who is close with Kobach and who traveled to the state to campaign for him. Vice President Mike Pence also stumped for Kobach.

Kelly, a state senator since 2005, faced criticism during the Democratic primary for being too cozy with the National Rifle Association and supporting a bill that allowed people to carry a concealed weapon without a permit. Kelly said she realized the bill went too far and supports restrictions on carrying weapons on college campuses.

She has also said she wouldn’t back new abortion restrictions and was endorsed by Planned Parenthood and EMILY’s List. Kelly has supported increased funding for education after the Kansas Supreme Court ruled the state had to increase school funding.

She also proved to be a strong fundraiser in the campaign, while Kobach relied on funds from his running mate, Republican lieutenant governor nominee Wink Hartman. Raising so much money allowed her to present herself as a credible alternative to Kobach, Bob Beatty, a political science professor at Washburn University in Topeka, told HuffPost last week.

Kelly will be sworn in as the state’s 48th governor in January.