The worshipers waited four years and 39 public hearings for the official denial: Muslims in their small New Jersey town would not be allowed to build a mosque.

The 2015 decision made by the planning board in Bernards Township, N.J., a majority-white suburb of 26,000 people, came after significant public opposition to the mosque that thrust the community into the national spotlight and spurred religious discrimination lawsuits from the Islamic Society of Basking Ridge and the Department of Justice.

On Tuesday, the township learned the cost of its six-year-old decision: $3.25 million.

As part of a settlement of the suits, the township must allow construction of the mosque to begin at its original proposed location, according to the Justice Department. Bernards Township will pay the Islamic Society $1.5 million in damages and $1.75 million in attorney fees and require town officials to submit to diversity and inclusion training.

“Municipalities around the country should pay close attention to what happened in Bernards Township,” Adeel A. Mangi, lead counsel for the mosque, told My Central Jersey. “The American Muslim community has the legal resources, the allies and the determination to stand up for its constitutional rights in court and will do so.”

The board hadn’t denied a building application for a house of worship in at least 20 years. It defended its 2015 decision by citing code changes created after the Islamic Society filed its application.

In 2011, the organization purchased a four-acre plot on Church Street for the mosque. It was in a residential zoning district that allowed places of worship, as long as they were built on properties with three or more acres.

Then in 2013, the township enacted a new ordinance that changed raised the minimum acreage to six. The township also said the mosque needed more parking spaces than churches or synagogues because of worship schedules.

In 2016, the Islamic Society sued the town in federal court and a Department of Justice complaint followed, alleging that the town discriminated based on religion.

A federal judge ruled on New Year’s Eve that the parking spaces decision violated anti-discrimination laws, and last week the town agreed to end the legal battle and settled.

“If the township had continued litigation, there was significant risk of exceeding insurance coverage and the possibility of denial of coverage under certain exclusions,” the township said in a statement to My Central Jersey. “With Judge Shipp as the presiding judge, and his honor’s decision on parking, as well as his prior ruling on similar matters, the township believes settlement was the best option.”

The town still “vehemently disagrees” with the judge’s ruling, though, according to the statement, but said that Bernards remains a “united township where all are welcome.”

“Opinions may still be varied, but it is in the best interest of the township to settle the litigation,” the statement said.

In the settlement, the Islamic Society agreed to reduce the number of parking spots, limit occupancy to 150 people and install no external speakers on the building. The Muslim call for prayer cannot be played outside and the mosque’s minarets may have only ornamental lighting, reported My Central Jersey.

“Federal law requires towns to treat religious land use applications like any other land use application,” Acting U.S. attorney William E. Fitzpatrick said in a statement. “Bernards Township made decisions that treated the Islamic Society of Basking Ridge differently than other houses of worship. The settlement announced [Tuesday] corrects those decisions and ensures that members of this religious community have the same ability to practice their faith as all other religions.”

More from Morning Mix: