HARRISBURG, Pa. — The highest court in Pennsylvania, heart of the country’s natural gas drilling boom, on Thursday struck down significant portions of a law that limited the power of local governments to determine where the industry can operate — rules the industry sought from Republican Gov. Tom Corbett and lawmakers.

In a 4-2 decision, the Pennsylvania Supreme Court ruled the industry-friendly rules set out by the 2012 law violated the state constitution, although the majority did not entirely agree on why they were unconstitutional.

Seven municipalities had challenged the law that grew out of the state’s need to modernize 20-year-old drilling laws to account for a Marcellus Shale drilling boom made possible by innovations in technology, most notably horizontal drilling and hydraulic fracturing. The process, also called fracking, has drawn widespread criticism from environmentalists and many residents living near drilling operations.

“Few could seriously dispute how remarkable a revolution is worked by this legislation upon the existing zoning regimen in Pennsylvania, including residential zones,” wrote Chief Justice Ron Castille. He said the law’s rules represented an unprecedented “displacement of prior planning, and derivative expectations, regarding land use, zoning, and enjoyment of property.”

The high court’s decision comes at a time when the energy industry is increasingly able to capture oil and gas from previously unreachable formations and, as a result, is bumping up against suburban and urban expectations of land use in states including Texas, Colorado and Ohio, where a similar legal challenge is underway.

The 2012 law restricted local municipalities’ ability to control where companies may place rigs, waste pits, pipelines and compressor and processing stations, although the new zoning rules never went into effect because of court order after the towns sued. A narrowly divided lower court struck them down in 2012, but Corbett appealed, saying lawmakers have clear authority to override local zoning.

Among the objectionable provisions cited by the lawsuit were requirements that drilling, waste pits and pipelines be allowed in every zoning district, including residential, as long as certain buffers were observed.

“It’s a tremendous victory for local governments, for local democracy, for public health and for the environment,” said Jordan Yeager, one of the plaintiffs’ lawyers. “It’s a huge, huge victory for the people of Pennsylvania.”

The municipalities argued the zoning restrictions ran counter to objectives of protecting the environment, health and safety of people who live there, and three of the six justices agreed. A fourth justice ruled that the law violated the municipalities’ constitutional rights to due process to carry out community planning.

Environmental groups and Democratic lawmakers hailed the ruling, while Corbett, Republican lawmakers and industry groups responded with disappointment.

“We must not allow today’s ruling to send a negative message to job creators and families who depend on the energy industry,” Corbett said in a statement, and pledged to continue to work to help the energy industry thrive.

The sprawling law also toughened environmental regulations and slapped a drilling fee on the industry, and top Republican lawmakers said they were unsure whether the decision will ultimately invalidate new protections around waterways and the fees that have generated hundreds of millions of dollars.

A lawyer for Senate President Pro Tempore Joe Scarnati, R-Jefferson, said Thursday the high court decision is a setback that will reopen the door to legal fights between municipalities and the drilling industry that the Legislature had sought to settle.

The drilling industry flocked to Pennsylvania in 2008 to tap into the Marcellus Shale, the nation’s largest-known natural gas formation. Companies quickly sought the changes as a top priority, complaining of a complicated patchwork of municipal rules and efforts by some municipalities to use zoning rules to effectively ban drilling.

Corbett and Republican lawmakers backed the industry, approved them over the objections of Democrats, who called them “corporate eminent domain.”

Castille said supporters of the law did not fully acknowledge its practical effects in light of the coal and timber industries’ checkered record.

“The commonwealth’s efforts to minimize the import of this litigation by suggesting it is simply a dispute over public policy voiced by a disappointed minority requires a blindness to the reality here and to Pennsylvania history,” Castille wrote.

He said the geographic diversity of the state means “protection of environmental values … is a quintessential local issue that must be tailored to local conditions.”

Justice J. Michael Eakin said he would have upheld the law and had concerns about the power the majority gave to the state’s thousands of local entities at the expense of the Legislature.

“Giving standing to some 2,500 sets of local officials to sue the sovereign based on alleged violations of individual constitutional rights is misguided, and will have precedential repercussions — I fear we will soon face a tide of mischief that will flow from such an ill-advised notion,” Eakin said.