A federal judge ordered a Tennessee county on Wednesday to move ahead with opening a Muslim congregation's newly built mosque after a two-year fight from opponents.

The Islamic Center of Murfreesboro sued Rutherford County earlier in the day and asked District Judge Todd Campbell for an emergency order to let worshippers into the building before the holy month of Ramadan starts at sundown Thursday.

Federal prosecutors also filed a similar lawsuit.

The future of the mosque had been in question since May, when a local judge overturned the county's approval of the mosque construction. This month he ordered the county not to issue an occupancy permit for the 12,000-square-foot building.

Campbell ordered the county to move ahead on approving the mosque for use, although it wasn't immediately clear if that could happen by Thursday. Final inspection of the building is required.

The contentious fight over the mosque stems from a 2010 lawsuit filed by a group of residents who made repeated claims that Islam was not a real religion and that local Muslims intended to overthrow the U.S. Constitution in favor of Islamic religious law.

Those claims were dismissed, but opponents won with a ruling that overturned the approval to build the mosque on the grounds that county didn't give adequate public notice of the meeting.

Although the county advertised that meeting in the same way it has advertised others, the judge said extra notice was needed because the mosque construction was "an issue of major importance to citizens."

In court on Wednesday, U.S. Attorney Jerry Martin said the chancery court judge, in essence, created a separate "mosque standard" applicable only to someone who wants to build a mosque.

Citing acts of vandalism, arson and a bomb threat against the Islamic Center of Murfreesboro, Martin said, "The Muslim community in Rutherford County has been under siege for the last two years. Now, after doing everything right, they are told that they can't move in."

Martin asked the federal judge to fulfill a promise made by the congregation's religious leader, Imam Ossama Bahloul, to the children of the congregation that justice would be done and they would be allowed to worship in their new space.

The congregation is being represented by The Becket Fund for Religious Liberty and local civil rights attorney George Barrett. The suit filed in federal court in Nashville alleges violations of federal law and the constitutional guarantees of freedom of religion and equal protection.

"If ICM were a Christian church, it would have been granted a certificate of occupancy and would be worshipping in its new facility today," a memorandum to the federal court reads, citing 20 instances of Christian churches that have been allowed to build since 2000. " ... The discriminatory treatment of the mosque also sends a powerful message to the Muslim community that they are second-class citizens, not worthy of the same rights or protection as Christian churches."

Attorneys for Rutherford County did not oppose the temporary restraining order. County attorneys have argued in chancery court hearings that treating the mosque differently from other applicants was discriminatory and a violation of their rights.

County Attorney Jim Cope said after the hearing that he felt vindicated by Campbell's ruling.

Mosque leader Bahloul said he had been reluctant to involve the mosque in the lawsuit but felt he had no choice after the certificate of occupancy was refused.

He said Campbell's ruling means a lot to Muslims in Tennessee and their supporters.

"I think this is an opportunity for us all to celebrate the freedom and liberty that, in fact, exist in America and to teach our young people to believe even more in the U.S. Constitution," he said.

An attorney for the mosque opponents did not return a call seeking comment.