Maryland’s House of Delegates voted Friday to ban hydraulic fracturing for natural gas, while also approving a Hogan administration bill that would let the state invest in potentially less costly ways of reducing stormwater pollution fouling the Chesapeake Bay.

The fracking ban, approved on a 97 to 40 vote, comes after a six-year debate over whether to allow the controversial energy extraction technique in the state. More than a dozen counties and cities adopted local ordinances or resolutions to ban fracking, and opponents have staged several rallies in Annapolis since the legislative session began in January.

Ban supporters argued that fracking contaminates drinking water wells, harms the health of people living in the vicinity and threatens to ruin Western Maryland’s significant outdoors-related tourism industry. Legislators from the region, though, appealed to their colleagues not to ban the practice, saying their constituents desperately need an economic boost. Fracking is widespread in neighboring states, ban opponents pointed out, and contended it can be done safely.

But Del. Kumar Barve, a Montgomery County Democrat and cosponsor of the bill, said the evidence from a growing body of studies indicated otherwise.

“In the instance of hydraulic fracturing, I think the science has spoken, and we should terminate this practice here in Maryland,” Barve said.

The ban faces an uphill struggle in the Senate, where leaders say they’re unwilling to let the bill out of committee — even if it could pass — unless it can garner enough votes to override a likely veto from Gov. Larry Hogan. It has 23 cosponsors now, one short of a majority but six shy of a veto-proof margin.

Unless lawmakers act this year, a moratorium on fracking overwhelmingly approved by lawmakers two years ago is slated to end Oct. 1. A competing bill in the Senate would continue the moratorium for another two years to allow still more time for study.

Hogan has indicated the he supports fracking if it can be done safely, and the Maryland Department of the Environment proposed rules late last year that administration officials asserted would offer a “platinum” level of protection for people’s health and the environment. But members of a joint legislative committee found numerous flaws and shortcomings in them, and they are still pending.

Meanwhile, the House gave nearly unanimous approval to the “Clean Water Commerce Act,” one of Hogan’s legislative priorities — but only after its purpose and scope had been significantly altered.

As introduced, the bill would have let the state divert $10 million from funds dedicated to upgrading wastewater treatment plants and use the money to buy nutrient reduction “credits.” Administration officials said they wanted it to help jump-start Maryland’s fledgling nutrient trading program. Under the program, individuals or businesses could reduce pollution more than required on their property and then sell “credits” for those extra reductions to others needing to meet pollution limits.

But environmentalists opposed the measure as vague, and objected to using the funds to pay farmers for pollution-reducing practices, saying they already get lots of other government financial help for that. Local officials also protested, saying funds are still needed to upgrade more wastewater treatment plants. The administration agreed to limit the diversion of wastewater upgrade funds and to invest only in “cost-effective” projects aimed at reducing stormwater pollution in urban and suburban localities.

The Senate unanimously approved its version of the Hogan bill last week.