ST. PAUL, Minn. (AP) — Minnesota’s Senate added language to a bill Thursday that would legalize gun silencers — a surprise development as majority Democrats had shown little interest in changing the state’s gun laws and a direct challenge to Gov. Mark Dayton’s promise that such a measure would meet his veto pen.

The silencer language was added to a grab bag of policy changes that would also mandate external investigations for officer-involved deaths, set ground rules for law enforcement’s use of drones and restore voting rights to felons after they’re released from prison. The full bill passed 39-22, with most Republicans voting against it.

The debate quickly veered into Minnesota’s gun laws, with a rural-district Democrat’s successful amendment to lift the state’s ban on silencers, also called suppressors, along with a handful of other gun law changes.

It’s an unexpected turn that puts the Senate in line with Republicans who control the House, which earlier this month passed a bill to legalize silencers. And it’s a marked turnaround for gun rights advocates, who just two years ago fought off a push to expand background checks and tighten gun access in the wake of the 2013 Connecticut school shooting.

The debate two years ago had clearly worn on Senate Majority Leader Tom Bakk, himself a frequent hunter and gun rights supporter. He said earlier this year he’d “like to stay out of the gun conversation.”

Find Out Who Is Pushing Silencer Legalization The Most 

But gun rights groups such as the National Rifle Association and the Minnesota Gun Owners Civil Rights Alliance hammered out a compromise with the Senate that allowed the silencer language to move forward. They call them suppressors, noting that they don’t silence gunfire but merely muffle it to slightly less harmful volumes.

Democrats from rural districts united with Republicans to tack on the suppressor ban repeal, which passed on a 40-23 vote. Sen. Lyle Koenen’s amendment also removed a requirement that gun permit owners alert public safety officials when bringing firearms to the Capitol or other state buildings.

Dayton tried to head off the vote earlier Thursday with a veto threat.

“I’m not aware that there is any part of the Second Amendment to the U.S. Constitution that gives us the right to bear a silencer,” the Democratic governor told reporters. “Suppression of gun noise heightens the risk to law enforcement officers and also innocent bystanders.”

That’s the same case some Senate Democrats made before voting against the silencer language, arguing that lifting the ban would lead to the spreading use of suppressors and ultimately hinder law enforcement’s “shot spotter” technology.

“I understand that it might be good in hunting, that it might help,” said Sen. Kari Dziedzic, DFL-Minneapolis. “I’m also asking you to understand the reality in certain neighborhoods, especially metro communities.”

The back-and-forth over suppressors didn’t match up to hours senators spent debating felon’s voting rights and the move to restore them right after prisoners are released — current law requires felons to serve out their probation terms before voting.

Advocates have pushed for the change for years, arguing it would give an estimated 47,000 felons an essential right as they move back into society. Some Republicans tried to slow down the transition back to voting, like one amendment that would have required that felons serve out two years of a probation or parole period.