An influential New Jersey Muslim leader accused by some federal officials of having terrorist ties but praised by others as being an important ally won his fight to gain permanent U.S. residency Thursday.

A federal immigration judge in Newark ruled that Mohammad Qatanani, the spiritual leader of the Islamic Center of Passaic County, can remain in the U.S.

The ruling brought cheers, tears and applause from about a dozen Qatanani supporters who gathered in the courtroom.

"I would like to thank the judge for working hard in this case," Qatanani said. "This is a beautiful thing. The justice system in this country is great."

U.S. immigration authorities had sought to deport Qatanani on grounds that he failed to disclose on his green card application a prior arrest and conviction in Israel for being a member of Hamas — a group classified as a terrorist organization by the U.S. government.

Qatanani has denied being a Hamas member and said he was detained, not arrested, by the Israelis while traveling to his native West Bank in 1993. He said he was not notified of the charges against him nor his conviction and that he was mentally and physically abused while in detention.

In ruling for Qatanani, immigration Judge Alberto J. Riefkohl questioned the reliability of the records submitted by the Department of Homeland Security purporting to show Qatanani's arrest and conviction in Israel. The judge called the U.S. government's case against Qatanani "patently incomplete," and found its two key witnesses — both federal agents — to not be credible.

Riefkohl also noted that Qatanani has received support from U.S. law enforcement officials, including U.S. Attorney Christopher Christie. Christie was among several high-ranking law enforcement officials who attended a Ramadan fast-breaking celebration at the Paterson mosque.

"My view is he's always had a very good relationship with us, and he's a man of great goodwill," Christie said Wednesday before exchanging traditional cheek-kiss greetings with Qatanani and wishing him well.

Harold Ort, a spokesman for U.S. Immigration and Customs Enforcement, said after the hearing that the government has not yet decided whether to appeal.

The 44-year-old Palestinian has served as the imam, or Muslim religious leader, since 1996 at the mosque in Paterson, a city that is home to one of the largest Muslim populations in the region. Thursday's decision means that Qatanani, his wife and their three foreign-born children can now become legal permanent U.S. residents. Any appeal must be filed within 30 days.

His immigration fight garnered national attention for the unusual spectacle of high-ranking law enforcement officials taking the stand on his behalf.

Christie, U.S. Rep. Bill Pascrell, D-N.J., the special agent in charge of the FBI's Newark office, county prosecutors, sheriffs and the director of the New Jersey Office of Homeland Security praised Qatanani and mosque members for helping to build bridges with law enforcement in the wake of the Sept. 11 attacks.

During Qatanani's immigration hearing, Jewish, Catholic and Episcopalian leaders testified that they viewed him as a moderate Muslim leader dedicated to interfaith outreach. Hundreds of his supporters kept a vigil outside the courthouse during his trial, which began in early May.

Qatanani emigrated from Jordan in 1996 on a religious worker visa to lead the New Jersey mosque. He applied for permanent U.S. residency in 1999 for himself, his wife and the three of their six children who were not born in America.

In 2005, he initiated a meeting with immigration officials to inquire about the delay in his green card application, during which he told them about his detention in Israel. U.S. officials later received documents from Israel that claimed he had been arrested and convicted.

Lawyers for the U.S. Department of Homeland Security sought to portray Qatanani as a terrorist-affiliated Muslim activist, quoting a sermon he gave at the Paterson mosque in which he called Israelis "transgressors" and questioning his ties to his brother-in-law, a convicted Hamas terrorist who was killed by the Israelis.

Government lawyers also said Qatanani had been an outspoken university leader during his student days in Jordan.

The judge found no credible evidence linking him to terrorism and wrote that family ties to a convicted terrorist do not make someone a terrorist.