As part of the settlement, the mosque will shrink to a height of 61 feet from a planned 66 feet. The Muslim group also agreed to have no outdoor amplification or street parking.

Mayor Michael C. Taylor of Sterling Heights said in an interview on Wednesday that despite the anti-Muslim rhetoric of some residents, the rejection really was about zoning. The city is home to two previously built mosques, as well as a Sikh temple and a Buddhist temple.

“The perception was that the city is denying a mosque because the city is not welcoming to mosques, and nothing could have been further from the truth,” he said. “We are very welcoming to the A.I.C.C., but there were legitimate zoning and planning issues that had to be worked out.”

Many of the irate residents, however, made clear they were not motivated by parking concerns. Mr. Taylor said much of the resistance to the mosque came from the city’s large population of Chaldean Christians, some of whom were refugees who fled religious persecution in Iraq. They see putting a mosque in their neighborhood as a provocation, he said.

Throughout the process, anti-Muslim sentiments flared. One public commenter held up a photograph of a woman wearing a garment that covered her head and said he did not want to “be near people like this,” according to the Justice Department complaint. Another resident suggested that weapons might be hidden in the mosque. Still another said officials should screen the American Islamic Community Center’s members because “they’re cutting people’s heads off; they kill our soldiers.”

The Muslim group sought to build the house of worship after it outgrew its current mosque in nearby Madison Heights. About 70 percent of its members live in Sterling Heights, and many have lived there for decades longer than those opposing the mosque, said Azzam Elder, the lead lawyer for the community center.

He called the decision “a victory for all Americans, especially vulnerable Americans.” The group’s members, he said, “feel very relieved, because the city of Sterling Heights finally realized who they are: They’re veterans who have served in the U.S. military; they’re professionals; they’re everyday Americans.”