(Jonathan Newton/The Washington Post)

After years of resisting, and over the objections of the state teachers union, Maryland lawmakers have agreed to state-funded private-school scholarships.

The decision to create a $5 million grant program was part of the negotiations on the state’s $42 billion operating budget, which received final approval in the Democratic-controlled General Assembly on Tuesday.

Lawmakers did away with a proposal that had been approved by the Senate and would have provided tax credits to companies that contribute to scholarships for students at private schools. Instead, the House of Delegates and the Senate backed the grant program, which will provide scholarships to students from poor families.

“It’s a win-win for not just the people of the state of Maryland, but for all students,” said Senate President Thomas V. Mike Miller Jr. (D-Calvert). “It’s a good compromise.”

Maryland joins 16 states that contribute public money toward private-school scholarships. Most of the others, including Virginia, Georgia, Florida and Alabama, have Republican-controlled legislatures and offer tax credits to companies or individuals who donate to the scholarship programs.

Maryland Gov. Larry Hogan (R), who has pushed for education tax credits for the past two years, said the scholarships have “the potential to make a huge difference to students and families across the state.”

Bills to create an education-tax credit in Maryland have been introduced for the past 10 years and had won the support of Martin O’Malley (D), who was governor from 2007 to 2015. The bills had advanced in the Senate, but not in the House, where they were staunchly opposed by House Speaker Michael E. Busch (D-Anne Arundel).

This month, Busch hinted that his opposition was softening, in part because two African American lawmakers from Baltimore — Dels. Antonio Hayes and Keith E. Haynes — had sponsored versions of the scholarship legislation. They and other members of the Democratic caucus argued that the aid was needed to help young black men in the city.

Miller said former Baltimore Mayor Kurt L. Schmoke, who is now the president of the University of Baltimore, also pushed for the scholarships, calling private schools “a lifesaver” for many Baltimore students in need.

The grants would be administered by the Maryland State Department of Education. The rules for the program would be set up by an advisory board that would be appointed by the governor and legislative leaders.

The Maryland State Education Association had fought hard against bills intended to create education tax credits. Such legislation would have set aside as much as $50 million for the program. But the union also vowed to fight the scholarship program, which Sean Johnson, the union’s assistant executive director, called a “voucher program” that would divert public money away from public schools.

“We’re hoping to make it a one-year bad idea and not a permanent bad idea,” Johnson said.

In approving the state budget, both chambers reallocated $80 million that Hogan wanted to put into the state’s reserve fund, also known as the Rainy Day Fund, to pay for Democratic legislative priorities.

John Rohrer, the coordinator of fiscal and policy analysis for the Department of Legislative Services, said the money will go toward uses including increasing reimbursement rates for doctors who treat the poor and helping local governments fund teacher pensions.

The money is fenced off, which means that if Hogan elects not to use it as Democrats want him to, it cannot be used for anything else. Last year, the General Assembly fenced off $65 million for several Maryland school districts. Hogan objected and did not release the funds.

Also Tuesday, the Senate voted to approve bills that would raise the mandatory retirement age for judges from 70 to 73; require schools to teach lessons aimed at preventing child sexual abuse; and reform the industry that specializes in purchasing structured settlements, giving the attorney general the authority to regulate the transfers of structured settlements.

In the House, lawmakers gave final passage to a measure requiring the Board of Public Works to notify the legislature and the public three days before voting on proposals to reduce budget appropriations. The three-member board has the authority to cut line items in the capital and operating budgets by up to 25 percent when the legislature is not in session.

The legislation goes to Hogan for his signature.

The House also gave preliminary approval to the capital budget and to bills that would prohibit the sale of powdered alcohol; mandate that drug prescribers and pharmacists use a database that helps identify health-care providers who overprescribe pain medications and patients who are misusing the drugs; and require insurance companies to cover all in vitro fertilization procedures involving donated sperm.

The in vitro measure would address a concern raised by Maryland Attorney General Brian E. Frosh (D) about a law passed last year that requires insurance companies to cover the procedure for same-sex couples using donor sperm.

Frosh said the statute created a disparity between same- and opposite-sex couples, the latter group not being guaranteed coverage. The Affordable Care Act prohibits such unequal treatment, Frosh said.

Josh Hicks contributed to this report.