The site that was proposed for a mosque at the end of a dead-end block in Bayonne, N.J. Photographs by Stephen Speranza for The New York Times

BAYONNE, N.J. — They thought they had found the perfect place to build the first mosque and Islamic community center in this city’s history: an empty 8,500-square-foot warehouse at the end of a dead-end block, with room on its lot for 37 parking spots.

But since paying $1 million for the property in 2015, Waheed Akbar and his nonprofit group, Bayonne Muslims, have faced an angry campaign by local residents, graffiti slurs outside their temporary prayer hall and numerous zoning and planning hurdles.

What seemed to be a possible end of the line for the mosque came on Monday night, when after a heated, six-hour-long meeting at Bayonne High School, the city’s zoning board did not approve the idea.

But the federal Justice Department has since contacted the Bayonne Muslims group and said it would investigate the matter, Mr. Akbar said. The group is also planning to file a federal lawsuit to contest the denial.

The Justice Department declined to comment on the existence of an investigation.

The case is the latest of many nationwide in which a local municipality has blocked the construction of a mosque or Islamic school, ostensibly because of traffic, parking or zoning concerns. When federal investigators have looked deeper into these cases, however, they have often discovered evidence of discrimination.

A federal court has the power to order a municipality to nullify a zoning decision, and require it to redo the land use approval process. Often, however, municipalities are willing to settle once the Justice Department begins an investigation into whether religious discrimination was involved.

The Justice Department investigates claims of discrimination involving houses of worship under a 2000 statute, the Religious Land Use and Institutionalized Persons Act. But “the animus in the Muslim cases seems to be particularly strong,” said Faiza Patel, a director of the liberty and national security program at the Brennan Center for Justice.

A 2016 Department of Justice report, for example, found that once federal investigations into discrimination were opened, municipalities settled 84 percent of cases involving non-Muslim houses of worship, compared with 20 percent of cases involving Muslims. Seven out of the last eight suits brought by the department involved mosques or Islamic schools.

Waheed Akbar and his nonprofit group, Bayonne Muslims, have faced an angry campaign by local residents who oppose plans to build a mosque and Islamic community center. Stephen Speranza for The New York Times

With Donald J. Trump as president, some in the civil rights community are now worried that the Justice Department will be less active in its protection of mosques because of what Ms. Patel described as the administration’s “very anti-Muslim stance.”

Omar T. Mohammedi, a lawyer who has represented Muslim groups in such cases, said he was expecting the government to pursue some enforcement of religious land-use claims because Mr. Trump has said he will be strong on religious freedom issues. “But not to the level that Obama was doing it,” he said.

The number of religious land-use discrimination cases involving Muslims is growing. The federal government investigated 17 such cases from 2010 to 2016, compared with seven from 2000 to 2010. Locally, the New Jersey townships of Bernards and Bridgewater have faced investigations, and a lawsuit was recently filed claiming discrimination against a proposed mosque in Yonkers.

In Bayonne, a working-class city of some 63,000 people, Muslims lived for decades without their own mosque. In 2009, a diverse coalition from the community decided it was time to change that. They formed a nonprofit organization and rented a 1,500-square-foot room in the basement of a former Roman Catholic school, St. Henry’s, on a main street across from City Hall.

For years, said Mr. Akbar, 38, a founder and secretary of the group, “we never got any negativity from the neighbors. Everyone was very helpful,” But that changed when the group bought the two-story warehouse at 109 East 24th Street with the intent of renovating it into an Islamic center. The center would host prayers five times a day, religious classes for children, and a soup kitchen open to all.

The warehouse, which had been used by a roofing company and a marine supply business, seemed out of the way, tucked into Bayonne’s quiet, residential East End, which is isolated from the rest of town by Route 440 on one side and a set of train tracks on the other.

But what seemed to Mr. Akbar an advantage was a huge issue for some locals.

“It’s quiet and peaceful, that’s what we moved here for,” said Eric Loarte, 48, who lives a few doors down from the proposed mosque and was primarily worried about traffic. “That’s going to be taken away from us.”

But he also had other concerns. “They are trying to take over the block and the neighborhood,” he said of the Muslim community. And neighbors, Mr. Loarte said, were also afraid of what might be preached at the mosque. He noted that Omar Abdel-Rahman, the blind sheikh who masterminded the 1993 World Trade Center bombing, had preached at a mosque in nearby Jersey City.

“You never know,” he said. “It’s happened before.”

The anti-mosque cause was picked up by people across town, who formed a Facebook group and put up signs that said things like “Save Bayonne” and “Stop the Mosque.” One of them was Joseph Basile, the pastor of Grace Bible Fellowship, a local evangelical church, who said his house was vandalized several times after he posted the signs, including with a brick through the window.

The lot across the street from the site of the proposed mosque. Stephen Speranza for The New York Times

At a preliminary zoning hearing several months ago, he asked if members of the mosque “believed in Shariah law,” before being told by the board that the question was irrelevant.

“I thought it was very relevant, because I believe you cannot hold to Shariah law and the U.S. Constitution at the same time,” he said.

While he’s not sure how many local residents agree with him, “I don’t think a day has gone by in the past few months if I’m outside walking on Broadway that somebody doesn’t come up to me and say, ‘Thank you’ and I have no idea who they are,” he said.

Last October, someone spray-painted crude phrases against Muslims and the words “Donald Trump” outside the Muslim worship site at St. Henry’s school. Within hours, police arrested a 20-year-old Bayonne man. Mayor Jimmy Davis strongly condemned the hate crime.

On Monday, a group of Muslims stood to pray at the opening of the zoning meeting. In response, a group of Christians started reciting the Lord’s Prayer, witnesses said. Later, a woman began quoting verses from the Quran that she said condoned violence against non-Muslims, video of the meeting showed. She spoke for several minutes before zoning board members shut her down.

In the end, the vote was 4-3 in favor of the variance that the mosque needed to function in the residential neighborhood. But the measure needed five votes to pass.

“I do believe there is a place for a community center for our Muslim friends,” said Commissioner Louis Lombardi, who voted no. “I just don’t believe that it is this one.”

Since then, Mayor Davis has called for civility and patience. Bayonne Muslims is speaking with lawyers and other congregations who have faced similar challenges. The group lost its lease at St. Henry’s School in January, because with several hundred worshipers now on Fridays, the church said it had outgrown the small space.

Mr. Akbar said that he believes the bigoted voices against the mosque represent “a very small minority” in the city. He said Muslims have felt welcome there and that many other residents had expressed strong support of their civil rights.

“It’s going to be a really nice place,” he said, standing outside the empty warehouse. “We are not giving up on it.”