The state Senate voted 28-19 for final passage, agreeing to a number of changes the House of Delegates approved Wednesday.
The measure would require people who buy a handgun to submit fingerprints to state police, bans 45 types of assault weapons, and limits gun magazines to 10 bullets. It also addresses firearms access for the mentally ill.
"Together, with a strong coalition of advocates, and the people of Maryland who overwhelmingly support policies to reduce gun violence, we've chosen to take action by advancing strategies that work to save lives," Gov. Martin O'Malley said in a statement after the vote.
Maryland will become the first state in nearly 20 years to require potential handgun buyers to submit fingerprints to state police. Only five other states have a similar requirement: Connecticut, Hawaii, Massachusetts, New York and New Jersey.
Gun control advocates say the fingerprinting requirement will help keep guns away from criminals, because it will make people reluctant to buy firearms for those who are not allowed to have them. Opponents say the bill erodes Second Amendment rights and ultimately penalizes law-abiding citizens without focusing on lawbreakers.
Although the measure bans 45 types of assault weapons, people who own them now will be able to keep them. People who order the weapons before Oct. 1, when the law would take effect, also would be able to keep them.
People who have been involuntarily committed to a mental health facility won't be allowed to have a gun.
Critics noted that Maryland already has strong laws, including universal background checks and a seven-day waiting period to buy a gun. The state doesn't even have a loophole allowing for private sales at gun shows without the same background check that licensed dealers are required to obtain, said Sen. Allan Kittleman, R-Howard.
"We have those protections, and what we're doing here is basically saying to folks who are concerned about their Second Amendment rights is, you know, 'We don't care,'" Kittleman said.
But Senate President Thomas V. Mike Miller, who spoke of his own gun collection, noted that people will be able to keep the guns they have, even the assault weapons under the ban.
"It doesn't affect a single gun that anybody has," Miller, D-Calvert, said, noting shotguns and rifles are not affected.
Also on Thursday, Connecticut Gov. Dannel P. Malloy signed into law sweeping new restrictions on weapons and large capacity ammunition magazines in response to the Sandy Hook Elementary School massacre there.
The White House said Vice President Joe Biden called O'Malley and officials in Connecticut to thank them for working to pass gun laws. Biden has been leading President Barack Obama's efforts to urge Congress to pass federal laws to reduce gun violence.
O'Malley, who is weighing a presidential bid in 2016, proposed the Maryland bill in January. Some Republican critics contend the bill is more about building O'Malley's resume than public safety.
"This may be great for political aspirations, for presidential aspirations, to pound your chest. But honestly, after 12 weeks of work, the bill that's on the floor today will not improve safety of the citizens of Maryland one bit," said Sen. E.J. Pipkin, R-Cecil.
But Sen. Brian Frosh, D-Montgomery, disagreed.
"This bill will do something very important. This bill will save lives," Frosh said.
Another provision requires someone to report a lost or stolen firearm, another effort to keep guns out of the hands of people who are not allowed to have them. The measure also calls for $25 million to be made available for schools to invest in security such as locks, cameras and buzzer entrance systems.
O'Malley included $4.6 million in a supplemental budget this week to implement the bill. The money would pay for employees at a state police center to enforce the law.
Maryland's legislative session is scheduled to end at midnight Monday.