As President Obama visits upstate New York and northeastern Pennsylvania this week to discuss his education agenda, a separate issue looms large in the background: fracking, a practice that has transformed Pennsylvania's economy and divided New York, where a moratorium is in place.

Protesters on both sides of the issue are expected to greet the President. And while his trip highlights many unresolved issues related to America's new wealth of natural gas and oil, a growing number of communities are taking matters into their own hands. (Vote: "How Has Fracking Changed Our Future?")

From New York to New Mexico, more than 100 municipalities have passed fracking bans or temporary moratoriums, according to FracTracker, a nonprofit organization that compiles data on the oil and gas industry. The bans often put communities in direct conflict with states over the right to regulate the oil and gas industry. (See related story: "Health Questions Key to New York Fracking Decision, but Answers Scarce.")

A Far-Reaching Debate

At first glance, New Mexico's Mora County seems an unlikely battleground in the fight over fracking, which involves injecting wells with millions of gallons of water and chemicals to release trapped oil and gas.

Located in a rural northern part of the state, the county has fewer than 5,000 citizens, vast tracts of open land, and an unemployment rate nearly twice the national average. Still, despite its need for jobs and economic development, Mora County in May became perhaps the first county in the United States to ban fracking on its land. (See related quiz: "What You Don't Know About Natural Gas.")

John Olivas, chairman of the Mora County Commission, said the ban stems from fear that fracking might harm water wells, which have flowed despite several recent summers of severe drought. "When you talk about an industry affecting our water, that is really all we have," Olivas said.

Many states across the country are in the midst of an energy boom propelled in large part by advanced drilling technologies, which allow companies to access oil and gas that could not be reached in the past. As drillers move into new frontiers, communities concerned over the health, safety, and environmental impact of fracking are passing strict regulations, moratoria, and outright bans, which often wind up in court. It's a trend experts expect will escalate. (See related story: "Natural Gas Nation: EIA Sees U.S. Future Shaped by Fracking.")

"I think we will see more municipalities and communities trying to ban fracking," said Sorrell Negro, a land use attorney in Connecticut who wrote an influential 2012 paper on the topic. In the past, drilling took place mainly on rural land, Negro said, but new technologies and recent shale discoveries have brought drilling into more densely populated areas.

"You are having places like the city of Dallas that have to decide if they are going to allow it in the city boundaries," Negro said. "These issues just have not come up before."

The trend of community bans has the oil and gas industry on edge. "This is an industry that operates on certainty," said Reid Porter, a spokesman for the American Petroleum Institute. "When you are looking at the planning necessary to make these investments in communities, it's necessary to know what the regulations are."

Industry representatives say drilling takes years of planning and millions of dollars of investment before the trucks arrive. If a local government has authority to ban drilling or enact regulations that make it too costly or cumbersome, drillers say it puts that investment at risk.

"The ability [of municipal governments] to change policy quickly would not elicit any sort of confidence," said Steve Forde, vice president of the Marcellus Shale Coalition, a trade association that represents energy companies targeting natural gas deposits in the 48,000-square-mile shale formation underneath New York, Pennsylvania, Maryland, Virginia, Ohio, and West Virginia. The Marcellus shale contains by far the largest known deposits of natural gas in the United States, and has turned the states where it is located into test cases for local control over fracking. (See related blog post: "In Virginia, a Tug of War Persists Over a National Forest Atop Shale Gas Reserves.")

What's unclear is how far energy companies are willing to go to protect their interests. Industry giants ExxonMobil and BP declined to comment on the issue, referring calls to industry trade associations. Shaun Goho, a lecturer and environmental law expert at Harvard Law School, said he expects industry will continue to push states to limit municipal regulation of fracking. "They want the states to handle it as much as possible," Goho said, "not local governments, and not the federal government."

Legal Uncertainty

State laws vary on the authority of local governments to regulate oil and gas development. In 2012, the Pennsylvania General Assembly passed statewide standards for oil and gas zoning, preempting the rights of municipalities to ban drilling or regulate where wells are sited. A handful of towns challenged the law and won in lower courts. The issue is currently before the Pennsylvania Supreme Court. (See related series: "The Great Shale Gas Rush.")

Since 2008, New York has enforced a statewide fracking moratorium while it prepares state regulations. In the meantime, several municipalities have passed bans and moratoria. In May, a mid-level New York appeals court ruled in favor of Dryden and Middlefield, two small upstate New York towns that banned fracking, affirming lower court decisions. Norse Energy, which has since filed for bankruptcy, had sued Dryden over its fracking ban.

Tom West, an Albany attorney who represents Norse Energy in the case, asked the state's high court to review the ruling. West said communities that ban drilling after energy companies buy leases will likely face further legal challenges. "Municipalities will have to think long and hard about that," West said, adding that he would recommend both that landowners and companies sue to protect the value of their mineral rights.

Deborah Goldberg, an attorney with Earthjustice, a nonprofit public interest environmental law firm that represents Dryden, said the case tests the rights of communities in the state to determine their future. "They are asking for the right to develop a well anywhere," Goldberg said of Norse Energy. "If they want to go in next to a school, they go in next to a school. If they want to go in next to a hospital, they go in next to a hospital, regardless of what the zoning says."

Battles over fracking are also brewing far from the Marcellus Shale, in western states including Colorado. In December, the Colorado Oil and Gas Association filed a lawsuit that seeks to overturn a fracking ban passed by voters in Longmont, a city of 85,000 northeast of Boulder. Colorado Governor John Hickenlooper's administration joined the lawsuit on the side of the drillers. In May, the Fort Collins City Council overturned its fracking ban, reportedly over concern over possible industry legal action, according to the Boulder Journal.

Stan Dempsey, president of the Colorado Petroleum Association, said in most cases Colorado fracking bans are little more than symbolic gestures in communities that have little or no energy development. In Longmont, for example, Dempsey said there was only one drilling operator. Nonetheless, Dempsey said, the industry spent $500,000 to influence the vote in Longmont and will continue to take cases to court.

"All of these communities are going to be sued for taking someone's mineral interests from them," Dempsey said. "I think it's a bit hypocritical for communities saying 'not in my backyard,' but we want the energy in our tanks and we want natural gas to heat our homes. I think so much of the opposition [to hydraulic fracturing] is really about opposing the development of fossil fuels. They don't want any more fossil fuel development, period."

As new technologies allow energy companies to target shale they were unable to drill in the past, experts say the legal challenges over fracking might be only beginning. The next battlefield may be in California, where drillers are eyeing the massive Monterey shale. The 1,750-square-mile formation in central and southern California is believe to contain double the oil of the Bakken shale, which made North Dakota into the second largest producer of oil behind Texas. (See related story: "Monterey Shale Shakes up California's Energy Future")

Because of the unique geology of the Monterey shale, it is unclear whether hydraulic fracturing would be an effective tool for oil production. After several recent legislative bills to halt fracking in California failed, activists started petition drives to block drilling in several cities and counties. If the activism leads to bans, industry watchers expect they will be tested in state courts.