Vice Chair of the Judiciary Committee Kathleen Dumias (D) talks about amendments as the Maryland House of Delegates prepares to vote on Senate Bill 281 on Wednesday in Annapolis. (Jonathan Newton/The Washington Post)

The Maryland Senate on Thursday gave final approval to Gov. Martin O’Malley’s far-reaching gun-control legislation and advanced a measure restructuring the Prince George’s County school system.

The schools bill passed 39 to 7 and went to the House, where its prospects for passage in the coming days appeared strong.

The gun bill, which passed 28 to 19, was sent to the governor’s desk, and aides said O’Malley (D) would sign it into law as early as next week.

As expected, Senate Democrats signed off on changes made to the gun bill in the House of Delegates rather than risk running out of time working on a compromise before the legislative session ends Monday.

Senate Republicans and some rural Democrats objected passionately. They said Senate leaders were choosing political expediency, especially in the area of access to guns by residents with mental-health problems.

“The fact is the Firearm Safety Act of 2013 provides no safety,” said Senate Minority Leader E.J. Pipkin (R-Cecil). “It says, if you own guns, we’re coming for you. That’s the message.”

Senate President Thomas V. Mike Miller Jr. (D-Calvert) pushed back against the criticism.

“This bill is a compromise. It says to law-abiding gun owners like myself . . . and I have what some have called an arsenal . . . any gun that you have right now is protected,” Miller said. “All it is is prospective — for people in the future” who buy guns.

In a statement, O’Malley called the bill “a comprehensive, common-sense approach to licensing and gun safety.”

The law, which is scheduled to go into effect Oct. 1, will give Maryland some of the nation’s most restrictive gun measures. The state will ban magazines that hold more than 10 bullets and will ban 45 types of semiautomatic rifles, classifying them as assault weapons. It will also require those seeking to buy any gun other than a hunting rifle or shotgun to obtain a license, a process that will include submitting fingerprints to police, passing classroom and firing-range training and undergoing more extensive background checks.

O’Malley, whose second-floor State House office is near the Senate balcony, made a brief appearance in the gallery, watching the last of more than 60 hours of public testimony and debate that also drew among the largest crowds to Annapolis in three decades.

Also in the gallery was Prince George’s County Executive Rushern L. Baker III, who watched the Senate debate a bill that would give him power to select the county’s new school superintendent, appoint three new members to the Board of Education and choose the board’s chairman and vice chairman.

During a speech in Denver to amp support for gun-control legislation, President Obama renewed pressure on Congress to enact stricter background checks. (Nicki Demarco/The Washington Post)

Baker (D) had sought a complete overhaul of the struggling school system, arguing that its performance hindered the county’s ability to attract businesses and new residents.

The compromise, though far short of what Baker initially sought, would still give Baker more authority over the county’s schools than any other county executive in Maryland.

The measure advanced after objections from Sen. C. Anthony Muse (D-Prince George’s), who called the legislation a “bad plan” that would give Baker power without setting any guidance for improving student achievement. A handful of other senators also objected, saying the county appeared to be getting special treatment on a bill introduced late in the session by Baker and supported by Miller.

Miller called Baker “very courageous.” He said the measure would allow residents to hold someone accountable for student progress.

Sen. Paul G. Pinsky (D-Prince George’s) defended the measure, saying Prince George’s is facing an urgent situation, hiring a new superintendent after having seven at the helm over 14 years.

The action on gun control and the Prince George’s schools came amid a busy day during which lawmakers advanced dozens of other bills.

The Senate sent a bill to the governor on a 36 to 11 vote that is designed to help implement the federal health-care law in Maryland.

Another bill given final approval by the Senate would make cyberbullying a crime. The bill was introduced after last year’s suicide of a 15-year-old Howard County girl. The girl’s family said she took her life after being harassed online.

The case sparked international interest. “American Idol” stars sent out tweets of support, and Baltimore Ravens running back Ray Rice campaigned on behalf of the measure.

Under the legislation, creating a fake profile, posing as a minor, posting real or doctored images of a minor and signing up a minor for a pornographic Web site would be misdemeanors punishable by up to a year in jail and a $500 fine.

The Senate also signed off unanimously on a bill that will eventually boost annual state education spending in Prince George’s by more than $13 million a year, another Baker priority.

The House on Thursday advanced a measure to give illegal immigrants driver’s licenses.

Meanwhile, a conference of House and Senate lawmakers signed off on a compromise of the state’s nearly $37 billion budget, increasing spending 3 percent in the fiscal year beginning in July.

John Wagner contributed to this report.