TOPEKA, Kan. — Kansas voters rejected the sharply conservative message of Kris W. Kobach, a Republican known for fiery warnings about election fraud and illegal immigration, and instead elected State Senator Laura Kelly, a Democrat, as governor of their red-leaning state.
Ms. Kelly’s victory on Tuesday, reported by The Associated Press, upended the Republican-controlled State Capitol in Topeka and stymied the political ascent of Mr. Kobach, the Kansas secretary of state, who has aligned himself with President Trump and has long been rumored to have his own presidential ambitions.
Ms. Kelly captured about 48 percent of the statewide vote to about 43 percent for Mr. Kobach. The result suggested a thirst for political moderation in a state Republicans have dominated. Democrats also flipped a Republican-held congressional seat in suburban Kansas City.
“There will be a lot of talk around America about the blue wave, but I don’t believe that’s what’s happened here in Kansas,” Ms. Kelly said as she declared victory on Tuesday night. “What happened in Kansas was a wave of common sense, a wave of bipartisanship.”
Ms. Kelly, 68, a longtime legislator from Topeka, focused her campaign on issues like Medicaid expansion, school funding and highway construction, winning endorsements from many prominent Kansas Republicans and votes from across the political spectrum.
She managed to win by large margins in several populous counties that favored Mr. Trump in 2016. She was leading by 16 percentage points in Johnson County, in the Kansas City suburbs, and by 23 percentage points in Shawnee County, which includes Topeka.
“I just feel like we need more Democrats in office to get our government back under control,” Melody Ross, 67, said on Tuesday outside her polling place in Topeka. Ms. Ross said she was a longtime registered Republican who was persuaded to vote for Ms. Kelly in part because of those Republican endorsements.
Mr. Kobach entered the race with a far higher profile than Ms. Kelly. Loved by conservatives and loathed by the left, Mr. Kobach for years helped local governments craft policies that put restrictions on illegal immigrants. In two terms as secretary of state, he acquired the power to prosecute voter fraud, crafted laws that restricted voting and was held in contempt of court by a federal judge who struck down some of that legislation.
During his campaign for governor, Mr. Kobach, 52, presented himself as an effective policymaker who did not yield to opposition. He promised to crack down on undocumented immigrants, cut the size of state government and reduce taxes.
“Some people on the left may disagree with some of the things I say,” Mr. Kobach told a crowd at a debate last month. But, he said, “I’ll deliver and I’ll get it done.”
At his watch party in Topeka, the mood turned somber soon after the polls closed. Mr. Kobach circulated through the crowd early in the night, pausing to pray with a group of supporters. But the crowd dwindled as Ms. Kelly ran up large margins and news agencies started to call the race for her.
Shortly before 11 p.m. local time, Mr. Kobach told the crowd that he had called to congratulate Ms. Kelly. “It was a tough, tough race,” he said. “We battled close to the very end. But this one just wasn’t God’s will.”
Ms. Kelly was relentless in trying to tie Mr. Kobach to former Gov. Sam Brownback, an unpopular Republican who left Kansas in January after presiding over big tax cuts and revenue shortfalls. Mr. Brownback, who served seven years as governor, was elected along with Mr. Kobach in 2010, and the two men have long shared a commitment to cutting taxes and enacting socially conservative policies.
Mr. Brownback, now a United States ambassador, promised Kansans that his signature tax cuts would provide a “shot of adrenaline” to the economy. But that growth failed to materialize, and the state was forced to make deep cuts to government services. Last year, a bipartisan group of lawmakers overrode Mr. Brownback’s veto and reversed most of the tax policy.
Mr. Kobach, who tried to distance himself from that policy on the campaign trail, said Mr. Brownback’s mistake was reducing taxes without first making large cuts to the size of state government.
Ms. Kelly, who has blamed the Brownback tax cuts for many of the state’s problems, reached out to Kansas’ sizable contingent of moderate Republicans and promised to work with members of both parties when elected.
“Partisanship was put above all else, and it tore our state apart,” Ms. Kelly said in her victory speech. “That ended today.”
Many have speculated that Mr. Kobach, who served as vice chairman of the president’s voter fraud commission, could soon join the administration. While stumping for Mr. Kobach in Topeka last month, Mr. Trump joked that “I hope he loses because I want him so badly.”
Kansas is firmly Republican territory, but this election cycle brought an unusual amount of national attention and close races. Democrats, who had been shut out of the congressional delegation, had hoped to flip two of the state’s four seats in the House of Representatives.
In the Third Congressional District, based in Kansas City, Kan., and the affluent Johnson County suburbs, Representative Kevin Yoder was beaten by Sharice Davids, a Democrat. Ms. Davids, a lesbian Native American, embraced her distinctive background while on the campaign trail.
Democrats came up short in the Second Congressional District, which includes most of eastern Kansas outside the Kansas City area. Their nominee, Paul Davis, who once served in the Kansas Legislature, narrowly lost to the Republican, Steve Watkins, a military veteran and political newcomer.