In a victory for opponents of the drilling process known as hydrofracking, a New York State judge ruled on Tuesday that the upstate town of Dryden in Tompkins County can ban natural gas drilling within its boundaries.

In August, Dryden’s Town Board used its zoning laws to pass a drilling ban, one salvo in a battle that is playing out nationwide as energy companies move to drill in densely populated areas. A month after the ban’s passage, Anschutz Exploration Corporation, a Colorado driller with 22,200 acres under lease in the town, filed a lawsuit arguing that the town’s authority did not extend to regulating or prohibiting gas drilling.

In a decision issued on Tuesday, Justice Phillip R. Rumsey of State Supreme Court said that state law does not preclude a municipality from using its power to regulate land use to ban oil and natural gas production. The ruling is the first in New York to affirm local powers in the controversy over drilling in the Marcellus Shale, a gas deposit under a large area of New York, Pennsylvania and Ohio.

It is a victory for hydrofracking opponents as New York State regulators revise an environmental impact document and propose drilling regulations to decide whether to allow the drilling and under what conditions. Dozens of other municipalities in New York have also adopted drilling bans and limits.