ALBANY, N.Y. — Environmental groups and a Steuben County village are heading to appeals court in their disagreement over the sale of water to a Shell Oil Company subsidiary for shale gas drilling in Pennsylvania.

The Sierra Club and People for a Healthy Environment won a court injunction in March 2013 stopping the Finger Lakes village of Painted Post from further water shipments under a 2012 contract with SWEPI LP, a Shell subsidiary drilling gas wells in Pennsylvania.

The five-year contract called for up to a million gallons of water per day shipped by rail, and Painted Post officials anticipated earning up to $2.5 million a year on the deal.

But a trial judge ruled that Painted Post officials improperly conducted the project’s environmental impact review and halted the sales, a decision the New York State Conference of Mayors says could endanger thousands of water-sale contracts that help financially struggling towns in New York.

A state appeals court in Rochester will hear arguments Monday in the appeal by the village and SWEPI.

Joseph Picciotti, the lawyer representing Painted Post and SWEPI, didn’t immediately return a call for comment Thursday. But Jane Tsamardinos, a lawyer for the Conference of Mayors, wrote in a court brief in support of the appeal that “the trial court’s holding must be reversed to prevent yet another unfunded mandate on local governments and their taxpayers.”

Water is one of the main concerns for opponents of shale gas drilling, which requires millions of gallons mixed with chemicals and sand to hydraulically fracture, or frack, underground rock formations to release the gas. Opponents object to the quantity of fresh water used in the process and the huge volumes of polluted water that must be disposed of afterward.

New York has had a moratorium on shale gas drilling since it began an environmental and health impact review in 2008. But some municipalities have tried to profit from shale gas drilling across the border in Pennsylvania by selling water or landfill services for leftover dirt and rock from the drilling.

New York recently implemented new regulations that require a permit to withdraw more than 100,000 gallons a day from surface or ground water. The permit is supposed to take into account ecological needs and best water conservation practices and be equitable to all users, said Roger Downs of the Sierra Club Atlantic Chapter.

“The problem is that municipalities are assuming the responsibility for broad water withdrawal permits and then selling off the ‘surplus’ that they don’t immediately need,” Downs said. “We are concerned that more problematic withdrawals, like those related to fracking, will be done as third-party transactions through municipal water permits, rather than captured in the safeguards of the new permitting requirements.”

Painted Post’s wells have a permitted capacity of 4 million gallons per day, far exceeding the needs of the community, which uses an average of 230,000 gallons per day, so officials entered the agreement with SWEPI to sell some of the surplus.

In their lawsuit, the environmental groups successfully argued that if a city’s sale of water presents a significant environmental impact, the city must conduct a full review under state law. Downs said the large water withdrawals in Painted Post created the risk of increasing the salinity of the regional aquifer.

The lawsuit also challenged the construction of a water facility on land the village leased to the Wellsboro and Corning Railroad, which would load and transport the water.

The village and SWEPI contend the sale agreement is exempt from New York environmental review because it was a sale of surplus property. Tsamardinos said an environmental review of the water withdrawal was unnecessary because the village had already done a required review for the railroad loading facility.

If the lower court decision is upheld, she wrote, it will “open the floodgates of litigation against municipalities” over surplus water agreements. Also, the Conference of Mayors said, municipalities across the state hold thousands of accounts to sell surplus water to outside users, and those could all be subject to expensive environmental review if the lower court ruling is upheld.