BERNARDS TWP. -- The township committee voted unanimously Tuesday night to approve the construction of a mosque in a Liberty Corner neighborhood as part of a settlement agreement with federal authorities over allegations of discrimination.

The settlement ended years of debate and dissension, as well as two federal religious discrimination lawsuits, one from the Justice Department and the other by the Islamic Society of Basking Ridge, filed against the township after officials rejected the mosque.

The township will pay $3.25 million to the society and its legal firm, New York City-based Patterson Belknap Webb & Tyler. Aside from a deductible, the settlement will be paid by the township's insurance companies, not taxpayer money.

More than 75 people gathered Tuesday night in a Ridge High School auditorium to listen as the committee gave the green light to the 4,252-square-foot mosque.

Adeel Mangi, lead counsel for the Islamic Society in the federal litigation, said he was pleased with the vote.

He said the Islamic Society "will welcome all residents of Bernards Township to its mosque and we look forward to its opening in the near future."

Robert Raymar, another lawyer who represented the society, said he was relieved to be at the end of this long process. He said the two-hour hearing Tuesday was probably the shortest of the 39 lengthy meetings in the last five years.

"We're going to move full speed ahead," he said. "And finally get the mosque built."

At least five people, some of whom live near the proposed mosque, spoke before the board to express their continued concerns over parking, fencing and public health issues, among others, with the mosque site on Church Street. Several were applauded.

Before voting, planning board member Kippy Piedici said she found parts of the settlement problematic. She said, however, that "approving the application far outweighs the cost to the township for further litigation."

The saga over the mosque began in December 2011, when the Islamic Society bought the property for $750,000.

Ali Chaudry, the society's president and a former mayor of Bernards, said they took great care before picking the location, which was zoned for a house of worship.

A month later, the society went before the planning board for the first time, asking to build the mosque for their 65 members. In April 2012, the society filed its application for site plan approval, estimating 50 to 70 parking spaces.

Before hearings began, residents formed a protest group called the Bernards Township Citizens for Responsible Development. The group said the mosque will add to an already-crowded residential area and change their way of life.

The planning board in early 2013 told the Islamic Society it must increase the number of parking spaces to 110 at its 4.3 acres site.

Then in late 2015, after four years, 39 meetings and numerous protests, the planning board voted 6-0 to reject the Islamic Society's final proposal citing lack of details regarding sufficient parking, traffic safety and buffer zones. It was the first denial of a site plan application for a house of worship since at least 1994.

The society then hired a law firm to file a federal lawsuit against Bernards Township, the township committee and its planning board for denying its right to build a mosque.

The Department of Justice launched an investigation over the township's planning board decision.

Months later, the society won in a landmark ruling, in which the court found that Bernards Township's insistence that a proposed mosque have more parking spaces than churches or synagogues was unconstitutional.

Luke Nozicka may be reached at lnozicka@njadvancemedia.com. Follow him on Twitter @lukenozicka. Find NJ.com on Facebook.