Montgomery County will pay $1.25 million to Bethel World Outreach Ministries to keep the Silver Spring megachurch from building on land that it owns in the county’s agricultural reserve, officials announced Monday.

Montgomery has long sought to limit development in the 93,000-acre swath that covers the northern third of the county. The settlement concludes seven years of court battles that pitted environmental concerns against constitutional guarantees of religious freedom.

Under the agreement, the county will purchase an easement on Bethel’s 119-acre site in Germantown that limits construction to four single-family homes. Bethel has instead purchased a property on Norbeck Road in Silver Spring once owned by Parker Memorial Baptist Church. Pending regulatory approvals, Bethel will be able to open a 1,200-seat church on that site.

“The church is very happy with the outcome,” said Bethel attorney Roman Storzer. “We believe that it’s a solution that protects everybody’s interests. “

The 2,500-member church has long been looking for space to expand. It bought the Germantown site in 2004 for $3 million at a time when the county permitted some churches in rural areas such as the agricultural reserve. But in November 2005 the County Council, under heavy pressure from environmental groups in an election season, denied Bethel’s request for a water and sewer permit. At the same meeting, the council passed a measure prohibiting public water and sewer service to any private institution in the agricultural reserve.

The church sued in state court, but the county prevailed. In 2008, Bethel sued again in federal court after the council denied permission for well and septic service on the Germantown property. It charged that the county’s action violated its rights under the First and 14th amendments and under the federal Religious Land Use and Institutionalized Persons Act.

Again, the county won in federal district court. But in January, the U.S. Court of Appeals for the 4th Circuit reversed one of the lower court’s judgments finding that the county’s land-use policies had placed a “substantial burden” on Bethel’s exercise of religion under the federal law.

Montgomery County Attorney Marc Hansen said the two sides began settlement discussions when the appeals court returned the case to district court for trial. Neither wanted the expense of a long, complex court case. It helped when the Norbeck Road property went on the market.

“The pieces sort of fell into place,” Hansen said.