The men have now been released on bail

The men were arrested last year in a hotel room in the city of Bauchi.

Prosecutors read out a letter from New York based Human Rights Watch calling for the court to respect the men's right to "free association".

The men were originally accused of sodomy, which could lead to the death penalty under Sharia, but the charges were reduced.

Prosecutor Yusuf Adamu said HRW was "grossly misinformed" about the case and invited a representative of the organisation to attend the trial.

Under Sharia law a man must dress like a man and woman must dress like a woman

Prosecutor Yusuf Adamu

The HRW letter was sent to the Federal Ministry of Justice in the capital, Abuja, who forwarded it on to the Bauchi state governor.

The letter said the Nigerian government had signed up to two conventions that enshrined the right to free association and freedom from harassment.

"Human Rights Watch is grossly misinformed. This case is not about the right to free association," Mr Yusuf said.

"Under Sharia law a man must dress like a man and woman must dress like a woman."

The 18 are charged with indecent dressing and vagrancy.

When the letter was read out the defendants looked relieved and happy, the BBC's Shehu Saulawa in Bauchi says.

But prosecutors have asked the court to write a response to HRW which could now delay the case.

Ancient customs

In the west, this case has focused attention on Nigerian attitudes to homosexuality, which is illegal in the country.

But the BBC's Alex Last in Nigeria says perhaps it is more a reflection of current attitudes within northern Nigeria to old local customs.

They are largely engaged in doing what was considered to be women's' work and could sometimes be hired as entertainers for parties.

Being a Dan Daudu, however, did not necessarily say much about a person's sexual preferences, our correspondent says.

But eight years ago Nigeria's northern states reintroduced some of the harsher penalties of Islamic law which had been removed under colonialism.

It was a response by politicians to a wave of popular discontent in the Islamic north against political corruption and social injustice.

This new tougher Sharia has largely failed to end such problems but there is now, perhaps, more of a willingness to target groups who appear to behave in ways that run counter to today's more puritan practice of Islam, our correspondent says.