A New Jersey township that rejected Muslims’ call for building a mosque must pay $3.25 million, which consists of $1.5 million in damages and $1.75 million in legal fees.

In 2011, the Islamic Society of Basking Ridge bought a 4-acre lot on Church Street to build a mosque there. The town planner at the time said he didn’t foresee any problems with the construction of a mosque.

However, after the Islamic Society submitted its plans, the local community erupted in anti-Muslim opposition to the construction plans.

“Flyers, social media, and websites denounced the mosque and were filled with anti-Muslim bigotry and references to terrorism and the 9/11 attacks,” court papers filled by federal prosecutors said.

Almost four years later, the township rejected the application. A lawsuit filed by federal prosecutors with the U.S. Department of Justice said the planning board “denied the application based on discrimination toward Muslims,” and sued Bernards Township in November 2016.

The prosecutors accused the township of violation the Religious Land Use and Institutionalized Persons Act of 2000, that protects religious institutions from discriminations.

The case was finally settled on Tuesday morning, with an agreement that will allow the Islamic Society to build to mosque. The township will also pay more than $3 million.