HELENA — A federal judge on Friday canceled nearly 300 oil and gas leases in Montana because government officials failed to properly study the risks of all that drilling to the environment and water supply.

The U.S. Bureau of Land Management sold 287 leases covering approximately 227 square miles of public land in central and eastern Montana in 2017 and in 2018. The agency's environmental reviews concluded that drilling would carry minimal risk to the areas' natural resources.

Three residents and two environmental groups sued in 2018, saying the agency didn't consider the risks of shallow hydraulic fracturing on groundwater or the cumulative effects of adding hundreds of drilling sites to the landscape. They also said the agency did not address the leases effects on the release of greenhouse gases and climate change.

U.S. District Judge Brian Morris sided with the plaintiffs, saying BLM officials didn't study what they were supposed to under U.S. environmental laws before going ahead with the lease sales.

"The Court does not fault BLM for providing a faulty analysis of cumulative impacts or impacts to groundwater, it largely faults BLM for failing to provide any analysis," Morris wrote.

The judge chided the BLM's attorneys for citing irrelevant findings from their environmental reviews to answer the plaintiffs' allegations, the judge said.

"A weatherman proves unhelpful if he says "it's going to be windy tomorrow" when asked if it will rain," Morris wrote in his ruling. "BLM proves just as unresponsive here."

The lease sales challenged in the lawsuit includes land adjacent to the Upper Missouri River Breaks National Monument. Other leased land include parcels near the Beartooth Mountains and the town of Livingston in the south and the along the Tongue River Valley in the southeast near the Wyoming state line.

The plaintiffs include Bonnie and Jack Martinell, who are farmers north of the Elk Basin oil field near the Montana-Wyoming line, and David Katz, who owns land along the Beartooth Front on the Stillwater River. They were joined in the lawsuit by the environmental groups WildEarth Guardians and Montana Environmental Information Center.

"The Bureau of Land Management was well aware that current oil and gas drilling practices would not protect sources of drinking water in these Montana communities, but rushed the sale anyway," said Elizabeth Forsyth, an attorney for Earthjustice, which represented the plaintiffs.

BLM spokesman Al Nash did not have an immediate comment on the ruling Friday afternoon.