TOPEKA, Kan. — Democrats running for Kansas governor are falling in line with the national gun-control movement stirring the party's liberal base, even if it means disavowing a loosening of gun laws in recent years that had been playing well in their gun-friendly state.

The top three Democratic contenders ahead of the Aug. 7 primary agree: Kansas has gone too far in recent years by allowing concealed guns on college campuses and letting people carry concealed guns without requiring a state permit or mandating training. They want to roll back those laws.

But one of them, state Sen. Laura Kelly, voted for those policies while representing a Republican-leaning district in the Topeka area — staking out positions that many Republican lawmakers did, including one just months after a mass shooting killed 20 children at an elementary school in Newtown, Connecticut, in December 2012. Kelly has been on the defensive about those votes in recent forums for the Democratic candidates.

Kelly compiled a decade-long record of voting with gun-rights advocates — and her break with them illustrates the difficulties facing Democrats in conservative states. An amendment to the Kansas Constitution to bolster individuals' right to own guns passed with 88 percent of the statewide vote in 2010; another, declaring a right to hunt, received 81 percent in 2016. Kelly voted to put both on the ballot.

"All those votes make her a better, more attractive general election candidate," said Bob Beatty, a political scientist at Washburn University of Topeka. "But she's got to get through the primary."

Republican Gov. Jeff Colyer and other GOP officials are still stressing their gun-rights credentials. Democrats expect support for tighter gun laws to appeal to some independent and moderate GOP voters, particularly in the state's most populated urban and suburban areas.

But in the Democratic primary, it's clear what position plays best in the wake of a nationwide student movement that prompted protest walkouts even in Kansas communities after February's shooting at a high school in Parkland, Florida, that killed 17 people.

"I have been a strong supporter of Second Amendment rights, but it became very clear that we went too far, and I have begun to vote for legislation that restricts some access to guns," Kelly said during the Democratic candidates' most recent political forum Wednesday.

Kelly last year supported legislation to keep concealed weapons out of public hospitals and mental health centers. Her fellow Democrats backed the change, while Republicans split over it.

Another leading Democratic contender for governor, former Kansas Agriculture Secretary Joshua Svaty, said it's not enough for Kelly to break from her past voting record now, after making other "far-reaching" votes to loosen gun laws.

"Only now, when she's running for governor, has she begun voting in a different way," Svaty said after their most recent forum. Kelly appointed a campaign treasurer at the end of May 2017 but formally launched her bid in December.

Svaty had a solid gun-rights voting record as a Kansas House member from 2003 to 2009, before he became agriculture secretary. He represented a rural central Kansas district where registered Republicans outnumbered Democrats by more than 2-to-1. He supported a law authorizing state permits for people to carry concealed guns, as well as other gun-rights measures, but proposals to loosen gun laws even further came up after he left the Legislature.

But during their most recent forum, as Svaty called out Kelly for voting to loosen gun laws further, he said he always supported "reasonable" restrictions on guns.

The third top Democratic contender, former two-term Wichita Mayor Carl Brewer, was never a state legislator and didn't have a hand in a raft of policies loosening state gun laws over the past decade. He declared that the National Rifle Association would not support him now or "any other day."

"We must have reasonable training and reasonable control," he said.

All three candidates want to repeal the 2013 state law that allowed concealed weapons on college campuses. They're also critical of the 2015 law that allowed people to carry concealed without a state permit. They also favor banning bump stocks and "red flag" policies allowing courts to take guns from people deemed a danger to themselves or others.

All three have received a "distinction for the "gun sense" policies they're advocating from the nonpartisan Moms Demand Action group.

"There's energy around fighting for commonsense gun laws and electing people who are willing to do that," said Jo Ella Hoye, a Kansas City-area mother and local Moms Demand Action leader.