A six-year dispute in Stafford County over plans to develop an Islamic cemetery has ended, with the Justice Department dropping a religious discrimination lawsuit against the county this week after it agreed to let the plans go forward.

The battle that began in 2015 pitted the nonprofit All Muslim Association of America against Stafford officials who, the Justice Department argued, adopted land-use policies aimed at preventing the Islamic cemetery to be built near a cluster of homes that use private wells, while Christian “churchyard cemeteries” remained under looser restrictions.

The county board, backed by local residents, had adopted a 2016 ordinance prohibiting new cemeteries within 900 feet of an existing private well, perennial stream or reservoir — a move officials said was meant to match a portion of the state code for cemeteries that relates to public drinking water sources.

But the setback effectively prohibited the entire proposed Islamic cemetery site, located on 30 acres near the Marine Corps Base Quantico. Last year, the Justice Department and the All Muslim group sued Stafford in U.S. District Court.

The county — which denied that religion was ever a motivation — then reduced the setback restriction to 656 feet and later rescinded the ordinance while arguing that the site still did not have the consent it needed from surrounding neighbors.

Last month, Stafford officials agreed to settle its lawsuit with the All Muslim group, paying the organization $500,000 and allowing the cemetery plans to proceed.

The county also agreed to implement a procedure to address potential violations of the federal Religious Land Use and Institutionalized Persons Act, according to the Justice Department, which issued a statement this week announcing that it had filed a notice to have its lawsuit dismissed.

County officials said they are satisfied with the outcome.

“This matter has been resolved in the spirit of compromise and goodwill,” the county said in a statement.

Sikander Javed, president of the All Muslim organization, said the cemetery site will probably be developed early next year, with the ability to hold 15,000 graves. The group purchased the site after a smaller cemetery site it owns in Stafford began to reach capacity.

Javed said the organization, which caters to the Washington region’s growing Muslim population, is mindful of the water-quality concerns that some in Stafford County may still have.

The group’s burial procedures guard against potential contamination, he said.

“We are just like them: human beings,” Javed said. “We will not do anything to harm the water, their health and their safety. We are being really careful about that.”