Driven by soaring prices, empowered by federal mining law and cheered on by the Bush administration, energy companies have been unstoppable in recent years as they march through the Rocky Mountain West searching for natural gas.

This search, which affects about 60 million American homes that heat with gas, has a guiding rule: If companies can lease land, they can drill it. The rule has proved inviolable, even though the companies' newest drilling technique -- called coal-bed methane extraction -- has often enraged environmentalists and local ranchers by lowering water tables, souring streams with salt and scarring wild lands with wastewater pits and screaming gas compressors.

One county in the West has had the temerity and the wherewithal to break the rule of lease it and drill. Not one gas well has been drilled here in Gallatin County, where the Old West ranch culture has been replaced by the recreating ways of the New West bourgeoisie.

Affluent, well-educated newcomers from the East and West coasts have bought up and taken over this western Montana county in the past 15 years, turning it into a place where people go outside not to work the land, but to play on it. Laced with blue-ribbon trout streams and surrounded by four splendid ranges of the Rockies, Gallatin is where you can buy Victoria's Secret underwear in the morning and see grizzly bears in the afternoon. A pricey kitchen store on Main Street last month offered an evening lecture titled "Beyond Sushi."

When outsiders threaten the lifestyles and ranchettes of these latter-day settlers, they are quick to raise money, hire lawyers, seduce the media and round up local politicians.

That is precisely what they did when they heard that the energy division of the privately held J.M. Huber Corp., based in Edison, N.J., had leased mineral rights to about 16,000 acres in a part of the county sprinkled with high-end houses. And it has stopped Huber cold, at least so far.

The company has been stymied in the county for five years, even though Huber's geologists have said there could be half a trillion cubic feet of natural gas here, potentially worth hundreds of millions of dollars.

Americans consume about 23 trillion cubic feet of natural gas a year. The federal Energy Information Administration has described the Rockies as potentially "a Persian Gulf of natural gas." About 9 percent of the national supply now comes from coal-bed methane drilling, but that is predicted to increase sharply in the next decade.

The prolonged stalemate on drilling here is remarkable, considering that a similar attempt to hold back coal-bed methane drilling in Delta County, Colo., has been slapped down in state court, and also considering that the federal government has cleared the way in the past year for 39,000 coal-bed methane wells to be drilled in the Powder River Basin in neighboring Wyoming.

"We hope we have created enough of a hissy fit that the company is reluctant to come here," said Melissa Frost, conservation representative for the Greater Yellowstone Coalition, an environmental group based in Bozeman, the major city in Gallatin County.

That hissy fit, together with the lawyers and the political maneuvering that give it teeth, may yet fail to hold back the tide of coal-bed methane extraction, a shallow drilling technique that goes after gas lying in seams of coal. To get at it, drillers must first pump out huge quantities of water, which is often tainted with salt and other minerals. The process -- especially the disposal of huge quantities of foul water -- tends to be far messier and, environmentalists say, more destructive than conventional deep-well gas drilling.

Huber has not given up in Gallatin County. It is suing in state and federal court, and experts say the history of western mining law supports its claims. That law allows split ownership of the land, which creates a fundamental conflict.

Mineral rights on most of the disputed land in Gallatin are owned separately from surface rights and have been leased to Huber by absentee landlords. State and federal courts have generally ruled that energy companies, if they have valid leases to gas and oil beneath the ground, can operate on that land, even without the consent of owners who have surface rights. Most of the county's new landowners do not own mineral rights.

Huber representatives declined to be interviewed for this story. In an e-mailed statement, the company said it has followed the law, "but Gallatin County effectively blocked the right to drill through a series of zoning changes and the imposition of onerous conditions."

"After exhausting all other avenues in an effort to find an amicable solution," the company said, it has been given no choice but to "take legal action to preserve its property rights."

The energy company had the bad luck of trying to drill its first test well in one of the few rural parts of Montana that is part of a zoning district. That gave county officials the right, under state law, to impose drilling conditions to protect property values, wildlife and the county's rural character, according to Marty Lambert, the county attorney.

"Huber has to prove that the county imposed conditions that were arbitrary and capricious," Lambert said. "Clearly, what they propose doing is going to depress high property values here. I don't think Huber understood the kind of people it would be dealing with."

Those people, on average, are twice as likely as the typical Montanan to have a graduate degree, according to Census figures. They are also richer, more likely to have been born in another state and far more likely to be living off investment income than typical residents of Montana, according to Ray Rasker, an economist at the Sonoran Institute, a conservation foundation based in Tucson.

As such, these residents are a substantially different constituency than the ranchers and farmers who inhabit most of the Rocky Mountain regions where energy companies have succeeded in extracting coal-bed methane.

In those communities, lawsuits have tended to come well after the drilling began -- not before.

When Huber first rolled into Gallatin County, it quickly annoyed many of the upscale residents, according to a number of Gallatin County officials. At one early public meeting, a Huber official seemed to condescend to his audience, suggesting that because many in the crowd may have graduated from high school, they might be able to follow his presentation.

One of the very annoyed residents (even though he wasn't in the audience that day) was Dick Clotfelter. He is a Stanford University graduate and wealthy real estate developer from Seattle who moved to this county seven years ago. He lives in a large stone house he built on 100 spectacular acres not far from where Huber wanted to sink its first test well.

"People here are smart, and they are willing to put their money where their mouth is," Clotfelter said.

After Huber annoyed him, Clotfelter got on the phone and asked his neighbors, most of whom also own large houses, to donate money for a legal challenge. "We raised $50,000 in a weekend, from about 10 people, and $50,000 in the next few weeks," he said.

Local legislators were also quick to jump on board. They introduced bills in the state legislature intended to curtail the power of energy companies to drill over local opposition. (In the legislature, where oil and gas interests have considerable sway, the bills died in committee.) Winning over county officials -- Republicans and Democrats alike -- was especially easy, because many of them are also newcomers who moved to Montana to hike, fish and ski.

There is, however, a major breach in the unified front that residents have thrown up against coal-bed methane. In parts of the county without zoning, residents are squabbling over passage of new zoning laws to stop Huber.

In this dispute, the Old West suspicion of government infringing on property rights is pitted against the New West obsession with protecting one's new patch of paradise from ticky-tacky development.

Some new residents want to limit density to one house per 80 acres, which would raise the value of existing housing. Old-timers want to subdivide their large tracts of land in pieces as small as 10 acres, which would raise the value of their property.

"There are people in this county who are using coal-bed methane as an excuse to shut the gate on development now that they are here," said Phil Olson, a former county commissioner. Olson, too, has a financial stake in the squabble. He wants 10-acre development, which would maximize his profit as he sells off inherited land.

The fight has halted the creation of a new permanent zoning district to regulate land leased by Huber. A temporary zoning law, which had held off the company for the past two years, runs out in August.

When it lapses, county officials say they won't have a legal way to stop Huber. "I'm not sure there is a darn thing we can do," said one county official, who asked not to be identified for fear of angering his constituents.

Residents of the Bozeman Pass area in Gallatin County, Mont., have been able to thwart natural gas drilling there.