Gun rights advocates rally Feb. 6 in opposition to Gov. Martin O’Malley’s (D) gun control measure. (Jonathan Newton/The Washington Post)

Maryland Senate Democrats passed sweeping gun-control legislation Thursday that would make the Free State the first in nearly 20 years to require residents to submit to fingerprinting, training and background checks to obtain a license to buy a firearm.

The licensing provision is the centerpiece of Gov. Martin O’Malley’s response to the December school shooting in Newtown, Conn. — and one of the most ambitious legislative attempts nationwide this year on gun control.

Over objections from Republicans and some conservative Democrats who warned that fingerprinting would trample on Second Amendment rights, the bill passed the Senate 28 to 19 after 17 hours of sometimes-boisterous debate this week.

It now heads to the House of Delegates, where it could again face a blizzard of amendments and more heated debate. A “rally to prevent gun violence” is scheduled at the State House in Annapolis on Friday, and gun-rights activists are expected to descend on the capital as well.

In addition to licensing and fingerprinting measures, the Senate bill includes provisions that would ban assault weapons and ammunition magazines that hold more than 10 bullets in Maryland. Similar efforts by Democrats to reinstate a federal assault-weapons ban have been stymied in Congress so far.

On mental-health issues, the original bill by O’Malley (D) would have increased the likelihood that someone committed involuntarily would be banned from making subsequent firearm purchases. But the Senate took it a step further, banning guns for anyone admitted against his will for any length of time. In addition, Marylanders who voluntarily admit themselves for mental-health treatment after visiting an emergency room for such issues could be banned if doctors determine that they pose a risk.

Mental-health professionals have vigorously opposed any firearm restrictions on those who voluntarily seek treatment, saying that doing so could deter people from getting the help they need.

O’Malley, however, on Thursday said he thought that the Senate’s changes regarding mental health made the bill “stronger and better” than when he introduced it, and he said he would support the changes.

In a full day of debate Wednesday, Democrats fought through more than 75 amendments and votes seeking to weaken the bill, but they held firm in requiring gun buyers to submit fingerprints, complete four hours of safety training and undergo stronger background checks to obtain a license to purchase firearms.

Proponents of the licensing provision say requiring purchasers to submit fingerprints to police would reduce “straw” purchases, in which a family member, friend or acquaintance buys a gun on behalf of another person who might not qualify.

A Washington Post poll released this week found that 85 percent of Marylanders back the governor’s licensing plan, and 73 percent do so “strongly.”

Senate Republicans, however, successfully tacked on several measures giving more leeway in registering assault weapons. One would give those who currently own, but haven’t registered, assault weapons a grace period of the remainder of the year to do so. They also reduced financial and criminal penalties for failing to register firearms and slightly narrowed the definition of the assault weapons that would be banned.

Before the final vote Thursday, Republicans said that Democrats were building false hope that the licensing provision could stop another Newtown or Columbine and said Democrats’ fingerprinting plan would only erode the rights of law-abiding gun owners.

Senate Minority Leader E.J. Pipkin (R-Cecil) argued that Democrats’ efforts were misplaced and should be focused on better enforcement of current gun laws and the jail sentences of those convicted of gun crimes.

Sen. Christopher B. Shank (R-Washington) accused the Senate’s Democratic majority of seeking to gut a constitutional right on guns because they simply didn’t like it or didn’t understand the rural lifestyle and gun use that often comes with it.

Seven conservative Democrats joined Republicans in supporting a filibuster, but the effort fell one vote short.

Sen. Thomas M. Middleton (D-Charles) voted to end the debate, but then voted against the bill.

We’re chipping away at people’s rights. It’s a constitutional right that we are chipping away, and it’s a hard pill for me to swallow,” Middleton said.

By contrast, Sen. President Thomas V. Mike Miller Jr. (D-Calvert), who had said he opposed the fingerprinting requirement, voted for the bill.

Sen. Nathaniel J. McFadden (D-Baltimore) said the Senate was rightly focused on gun-control measures that would help prevent not just massacres, but also the daily gun violence that kills too many youths in Baltimore and Prince George’s County.

“Residents are sick and tired of this gun violence,” McFadden said. “No, this is not a perfect bill. Because you’re right — those criminals are not going to go and be fingerprinted,” he said. “But somehow these guns find their way into our communities . . . They come from somewhere, and you can get a gun quicker than you get an apple or an orange in my community. It’s outrageous, and we have to start somewhere.”