Democratic Sen. Brian E. Frosh (standing left) debates a Maryland gun-control bill with Sen. E.J. Pipkin (standing right), R-Cecil, on Tuesday, Feb. 26, 2013 in the state Senate in Annapolis, Md. (Brian Witte/AP)

Sweeping gun-control legislation proposed by Maryland Gov. Martin O’Malley (D) advanced in the state Senate late Wednesday, with lawmakers tightening restrictions on gun purchases by the mentally ill and offering token concessions on tough new licensing requirements.

In a rare bipartisan move, the Senate voted to go beyond O’Malley’s plan to limit gun purchases by residents committed against their will for mental-health treatment. The Senate chose to do that, as well as ban future gun sales to some Marylanders who undergo voluntary admissions, a threshold that mental-health professionals have opposed.

Senate Democrats, however, mostly worked to maintain the core of O’Malley’s plan. Over nine hours of debate, they fought off scores of attempts by Republicans and rural Democrats to weaken the bill.

A final Senate vote is expected Thursday, likely sending the measure to the House of Delegates, where a committee is scheduled to take up the issue Friday.

Democrats held firm in requiring gun buyers to submit fingerprints, complete safety training and undergo stronger background checks to obtain a license to purchase firearms. They also passed the bulk of O’Malley’s proposed ban on assault weapons and ammunition magazines containing more than 10 bullets.

“The key parts of it are still there,” said a weary looking Sen. Brian E. Frosh, the Montgomery County Democrat and Senate Judiciary Committee chairman who led proponents’ efforts to pass the bill. “It’s still an extremely important and, I suspect, extremely effective public safety measure.”

Vincent DeMarco, president of Marylanders to Prevent Gun Violence, agreed. “We are right where we need to be to enact a tremendous, life-saving measure. The governor’s bill is intact,” DeMarco said.

Senate Republicans successfully added several measures giving gun purchasers more leeway in registering assault weapons, lengthening a year-end grace period to do so. They also reduced financial and criminal penalties for failing to register firearms and slightly narrowed the definition of assault weapons that Maryland would ban.

The mental-health change to O’Malley’s bill, authored by Sen. Robert A. Zirkin (D-Baltimore County), would ban future gun purchases by patients who are admitted to a hospital for an emergency mental-health evaluation on the recommendation of a doctor, and who then agree to direct admission to a mental-health facility.

Zirkin said a broader but “more targeted” group of mental-health patients could face gun restrictions than under O’Malley’s plan. “These are people are presenting as a danger to themselves or others and have a mental disorder,” he said. “That’s the group we need to target.”