In a decision with far-reaching implications for the future of natural gas drilling in New York State, its highest court ruled on Monday that towns can use zoning ordinances to ban hydraulic fracturing, the controversial extraction method known as fracking.

Since the issue arose about six years ago, there has been a statewide moratorium on fracking, and the State Health Department is currently studying its potential health effects. But in recent years some towns, worried that the state would eventually allow the practice, have taken matters into their own hands by banning fracking within their borders. Among them, two towns — Dryden, in Tompkins County, and Middlefield, in Otsego County — amended their zoning laws in 2011 to prohibit fracking, on the basis that it would threaten the health, environment and character of the communities.

Subsequently, an energy company that had acquired oil and gas leases in Dryden before the 2011 zoning amendment, and a dairy farm in Middlefield that had leased land to a gas drilling company, filed legal complaints, arguing that state oil and gas law pre-empted the town ordinances.

On Monday, in a 5-to-2 decision, the State Court of Appeals affirmed a lower-court ruling rejecting that argument, and found that the towns did indeed have the authority to ban fracking through land use regulations.