Maryland Gov. Martin O'Malley (Patrick Semansky/Associated Press)

Maryland lawmakers gave final approval Friday to the first increase in the state’s gas tax in 20 years, acting to replenish a transportation fund that is rapidly running out of money for highway construction and long-planned mass-transit projects.

Under the bill, which passed the Senate 27 to 20, motorists can expect to pay between 13 and 20 cents more per gallon by mid-2016, according to legislative analysts. The increase would be phased in, with the first bump of about 4 cents a gallon coming in July.

The legislation, which transportation officials say would yield $4.4 billion for new projects over the next six years, passed the House of Delegates last week and now goes to Gov. Martin O’Malley (D), who introduced the bill, for his signature.

The vote came just a month after a transportation plan was approved in Virginia, a state led by a Republican governor that competes for jobs in a region with some of the nation’s worst traffic congestion.

The two plans share some features, including a new wholesale tax on gas that is intended to keep pace with the price of fuel.

Maryland gas tax (The Washington Post/The Washington Post)

Passage in Maryland also marked the latest legislative win for O’Malley in a 90-day session in which he has pushed through measures to repeal the death penalty and offer incentives to develop an offshore wind farm.

With barely a week left in the session, O’Malley also notched a victory late Friday in a House committee that had become a linchpin in his efforts to pass one of the most far-reaching legislative responses to last year’s deadly school shooting in Newtown, Conn. The governor’s bill survived challenges from Republicans and conservative Democrats, retaining an assault-weapons ban and a provision to fingerprint gun buyers. The vote sets the stage for passage before the legislature’s April 8 adjournment.

In an interview, O’Malley acknowledged that higher gas taxes would not be politically popular: “It’s not the kind of stuff people throw you bouquets for.” But he argued that funding more projects would create jobs and that the action was long overdue. He credited passage in Virginia for stiffening the spines of some lawmakers in Maryland.

“People became much more open to the need and the importance of moving forward on this when they saw our neighbors on the other side of the river were moving out ahead of us,” he said.

The Maryland Senate also passed a “lockbox” bill Friday that would make it more difficult for future General Assemblies to divert transportation funds to other programs — a strategy that has been used by governors and lawmakers from both parties to balance the state’s operating budget.

During Friday’s debate, opponents of the gas-tax bill — many who represent rural districts — protested that the plan places too heavy a burden on motorists to help pay for mass-transit projects they won’t use and that many residents can’t afford a tax increase.

“This is a regressive tax that hurts the poor,” said Minority Leader E.J. Pipkin (R-Cecil). “This is going to cause tremendous pain for everybody.”

Supporters countered that the bill would help fund projects in all regions of the state, including the congested Washington region.

“It’s an economic issue, and it’s a quality-of-life issue,” Senate President Thomas V. Mike Miller Jr. (D-Calvert) told reporters.

Based on current projections, state analysts say that after 2017, Maryland will have enough revenue only to maintain its transportation network, not for new highway construction or planned mass-transit projects, including the Purple Line rail link in the Washington area and the Corridor Cities Transitway rapid bus line along Interstate 270 in Montgomery County.

The plan passed Friday adds another layer of taxes to purchases of gasoline, which are currently subject to a 23.5-cent-a-gallon flat tax, a levy unchanged since 1992.

As of January, Maryland’s gas tax was the 29th highest among states, according to an analysis by the Tax Foundation, a nonpartisan research group based in Washington.

Once fully phased in, the bill passed Friday would catapult the state into the top 10, if projections by state legislative analysts prove true.

Under the bill, a new sales tax of 3 percent would be imposed on gas at the wholesale level. That tax would be phased in over three years, starting in July. An additional 2 percent could later be tacked onto the sales tax on gas if Congress doesn’t take action on a separate issue related to Internet sales.

Maryland and other states are lobbying the federal government to adopt a long-stalled plan to ensure that states can collect sales taxes when their residents buy from out-of-state Internet retailers.

If Congress acts on that by 2015, that revenue would be earmarked for transportation in Maryland. Otherwise, the additional 2 percent sales tax on gas would take effect.

Virginia has a similar provision in the transportation legislation championed by Gov. Robert F. McDonnell (R).

Some of the most vocal Republican opposition to the Maryland bill has focused on a provision that automatically increases the flat tax on gas in coming years to reflect inflation.

Pipkin said the automatic increases were a way for future legislatures to avoid having to find the “courage” to vote for more tax increases. “We shouldn’t be putting taxes on cruise control,” he said.

The projections by state legislative analysts seek to determine the effect of the various increases on a gallon of gas and involve several assumptions, including what the price of gas will be in the future. Under their projections, motorists could expect to pay an additional 13 cents per gallon by July 2016 if the Internet tax becomes law. If not, that amount would rise to 20 cents per gallon.

All 27 senators who voted for the tax bill were Democrats. They included all 16 who represent parts of Montgomery and Prince George’s counties. All 12 Republicans voted against the bill, and they were joined by eight Democrats.

In the House of Delegates, meanwhile, a pair of committees worked late into the evening on O’Malley’s ambitious gun-control package, with supporters fending off attempts to weaken several key provisions, including an assault-weapons ban and strict, new licensing requirements that includes fingerprinting.

The House Judiciary Committee and the chamber’s Health and Government Operations Committee, which have joint jurisdiction over the bill, debated amendments to the bill for more than eight hours, before voting 27 to 18 to send it to the full House of Delegates.

Disagreement over the scope of the assault-weapons ban had left the bill languishing for more than a month in the House, with even some key Democrats on the two committees saying an all-out ban seemed unnecessary given how rarely the weapons are used in Maryland killings.

Kate Havard contributed to this report.