This is the chronicle of how a founding principle of this country, the freedom to worship, crashed into a public bureaucracy in the venerable and prosperous New Jersey suburb of Bernards Township.

There, a brittle layer of shifting regulations sat atop a lava field of private contempt for Muslims on the part of some public officials who felt free to send email “jokes” that President Barack Obama was a Muslim, an illegal immigrant and a communist.

Most of all, it is a story of a rare phenomenon in American law: unconstitutional parking spots.

More than five years ago, the Islamic Society of Basking Ridge sought permits to build a mosque big enough for 150 people on a four-acre parcel, where zoning permitted houses of worship. Basking Ridge falls within Bernards Township.

This week, there is still no mosque — but five years of hearings and litigation about the proposal are drawing to a close. The Township Committee and Planning Board voted Tuesday night to settle lawsuits brought by the Department of Justice and the Islamic Society. Details of the settlement were not announced, but it will include the building permit long denied to the organization.