The Supreme Court on Monday removed a major obstacle to the construction of the Atlantic Coast Pipeline, a long-delayed and multibillion-dollar project meant to carry natural gas through some of the most mountainous scenery in central Virginia.

The court ruled that the U.S. Forest Service has authority to grant the pipeline right of way under the Appalachian Trail in the George Washington National Forest.

The 7-to-2 opinion was written by Justice Clarence Thomas. Justices Sonia Sotomayor and Elena Kagan dissented.

The Atlantic Coast Pipeline begins in West Virginia and would cross Virginia before completing its 600-mile path in North Carolina.

It has been delayed as builders contend with a host of setbacks handed down by federal courts. None is more crucial than the question of whether the pipeline may cross under the Appalachian Trial.

Judges from the U.S. Court of Appeals for the 4th Circuit threw out a Forest Service permit in December 2018, saying federal law prohibits any agency from approving a pipeline on “lands in the National Park System.” That includes the trail, the judges said.

The pipeline’s builders, led by Dominion Energy, appealed to the high court, saying the ruling could create an impenetrable wall along the trail’s course, which runs from Georgia to Maine.

“Simply put, there is no basis in any federal statute to conclude that Congress intended to convert the Appalachian Trail into a 2,200-mile barrier separating critical natural resources from the Eastern Seaboard,” the company told the court.

The plaintiffs note that existing pipelines cross the trail at 34 locations.

The Trump administration weighed in on behalf of the project, arguing that even though the National Park Service administers the trail, the land beneath it is controlled by the Forest Service.

Environmentalists opposing the construction argued that no pipeline has been granted a right of way across the trail on federal land since it became part of the park system. Other crossings are on private or state lands or on easements that predate federal ownership.

Trying to separate the land from the trail is an “elusively metaphysical distinction” that “contradicts the government’s own long-standing approach to administering the trail,” the groups told the court in their briefs.

Thomas said that the land the Appalachian Trail crosses still is under control of an agency that can approve the right of way.

“The lands that the trail crosses are still ‘federal lands’ and the Forest Service may grant a pipeline right of way through them — just as it granted a right of way for the trail,” Thomas wrote.

“Sometimes a complicated regulatory scheme may cause us to miss the forest for the trees,” he wrote. “But at bottom, these cases boil down to a simple proposition: A trail is a trail, and land is land.”

Sotomayor said the decision was “inconsistent with the language of three statutes, long-standing agency practice, and common sense.”

The Park Service is in charge of the land the trail traverses, and federal law does not permit pipelines “across such federally owned lands. Only Congress, not this court, should change that mandate,” she wrote.

Environmental groups condemned the decision.

“This is not a viable project,” D.J. Gerken, program director of the Southern Environmental Law Center, said in a statement after the decision was announced.

“It is still missing many required authorizations. . . . It’s time for these developers to move on and reinvest the billions of dollars planned for this boondoggle into the renewable energy that Virginia and North Carolina customers want and deserve.”

Kelly Martin, director of the Sierra Club’s Beyond Dirty Fuels Campaign, said: the “decision is just plugging . . . one hole on a sinking ship. . . . The fracked gas [in the] Atlantic Coast Pipeline is a dirty, dangerous threat to our health, climate and communities, and nothing about the ruling changes our intention to fight it.”

But Ann Nallo, a spokeswoman for the pipeline and Dominion Energy, backed the ruling.

“Today’s decision is an affirmation for the Atlantic Coast Pipeline and communities across our region that are depending on it for jobs, economic growth and clean energy,” she said in a statement.

“We look forward to resolving the remaining project permits,” she said. “For decades, more than 50 other pipelines have safely crossed the Trail without disturbing its public use. . . . The pipeline will be installed hundreds of feet below the surface. . . . There will be no construction activity on or near the Trail itself.”

West Virginia Attorney General Patrick Morrisey (R) also hailed the ruling, saying it “will help put back to work thousands of men and women.”

The controversial project has drawn national attention from environmentalists, including former vice president Al Gore. Approved by the Federal Energy Regulatory Commission in 2017, the pipeline initially was projected to cost about $5 billion but has ballooned in price with multiple delays.

Virginia Attorney General Mark R. Herring (D) filed a brief on behalf of the project’s opponents, arguing that the pipeline threatens “several of Virginia’s most cherished places.”

Earlier this year, the U.S. Court of Appeals for the 4th Circuit threw out a state permit for a compressor station in a historic African American community in Buckingham County, Va., saying the builders failed to consider whether the facility needed to move the gas along its way would unduly harm a minority group.

And the lower-court ruling on the Appalachian Trail crossing had three other elements that are not part of the appeal to the high court. Those judges also said the permit didn’t comply with mandatory standards for protecting soil, water and wildlife; that the agency didn’t take a hard-enough look at landslide and erosion risk; and that the Forest Service rejected alternate routes without fully analyzing them.

The consolidated cases at the Supreme Court are U.S. Forest Service v. Cowpasture River Preservation Assn. and Atlantic Coast Pipeline LLC v. Cowpasture River Preservation Assn.

Gregory S. Schneider and Michael E. Ruane contributed to this report.