Image caption There have been acts of vandalism and bomb threats against the Tennessee mosque

A US judge has ruled that a Muslim congregation has the right to occupy their newly built mosque, overturning a lower court order.

But county officials said they could not complete a final inspection to make the building ready for use on Thursday as the month of Ramadan begins.

Wednesday's ruling was the latest episode in a two-year legal battle over the Rutherford County mosque.

Residents filed a lawsuit against the place of worship in 2010.

The opponents said Islam was not a real religion and claimed Muslims wanted to overthrow the US constitution in favour of Islamic law.

Their lawsuit was dismissed, but in May this year they won a ruling on a technicality to overturn the completed building's approval.

Earlier this month, a local judge barred the county from issuing an occupancy permit for the Islamic Center of Murfreesboro.

'Under siege'

The mosque's representatives sued the county on Wednesday.

I think this is an opportunity for us all to celebrate the freedom and liberty that, in fact, exist in America Imam Ossama Bahloul, Mosque leader

They sought an emergency order allowing worshippers into the building in time for Ramadan, which starts at sunset on Thursday in the US.

US Judge Todd Campbell granted the motion, ordering the county to approve the mosque for use.

But Rutherford County building codes director David Jones told the Daily News Journal newspaper on Thursday that it could take two weeks before the site was ready for final inspection.

The US justice department also filed a lawsuit in the mosque's favour.

In court on Wednesday, US Attorney Jerry Martin argued that the local judge was holding the mosque to a different standard to other religious buildings.

The US attorney cited acts of vandalism and arson against the mosque. A Texas man was indicted last month on charges of making a bomb threat against the place of worship.

"The Muslim community in Rutherford County has been under siege for the last two years," Mr Martin said. "Now, after doing everything right, they are told that they can't move in."

Mosque leader Imam Ossama Bahloul told the Associated Press he had been reluctant to involve the mosque in a lawsuit, but felt he had no choice after they were refused occupancy.

Mr Bahloul said he was encouraged by Judge Campbell's ruling.

"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 US Constitution," he said.

A lawyer for the mosque's opponents told the Daily News Journal he believed the ruling had circumvented the public will.

"You don't throw a lawsuit like this together overnight," Joe Brandon said. "So, clearly, it's something they've been planning for some time."