Five Muslim men from Derby have gone on trial for allegedly handing out leaflets calling for gay people to be killed in the first ever prosecution under new legislation making such actions a hate crime.

The men, Ihjaz Ali, 42, Mehboob Hussain, 45, Umar Javed, 38, Razwan Javed, 27, and Kabir Ahmed, 28, are accused of handing out to passersby and posting through letterboxes a leaflet calling for gay people to be given the death penalty, and stating that gay sex is a great sin that leads to hell.

They are accused of stirring up hatred on the grounds of sexual orientation, the first prosecution under new legislation which came into force in March 2010. They deny the charges.

A jury at Derby crown court heard that the five men had handed out a leaflet entitled The Death Penalty? outside and near the Jamia mosque in Rosehill Street, Derby, in July 2010, as well as putting it through nearby letterboxes. The pamphlet showed an image of a mannequin hanging from a noose.

The leaflet was one of several that the men were distributing, but the charges relate only to one called The Death Penalty? the jury heard.

Bobbie Cheema, opening the case for the prosecution, said: "The leaflets you will see are not educational or simply informative. They are, we suggest, threatening, offensive, frightening and nasty."

A fourth leaflet, entitled Dead Derby, had been found but not distributed, she told the court. It described homosexuality as a "vile, ugly, cancerous disease" and stated: "Gay today, paedophile tomorrow?"

"A word of warning," she told the jury of seven men and five women. "This case is not about, and we must not make it about, an interference with the defendants' freedom of religion or freedom to express their religious views in an attempt to educate or inform people.

"The vast majority of Muslim, and indeed other religious people, or people with no religion but who have strong views about homosexuality, are able to express their views if they wish in a critical but lawful, moderate and self-controlled way. That's one of the rights we have."

Ali, of Fairfax Road, Derby, faces four counts while Hussain, of Rosehill Street, Normanton, and Umar Javed, of Whittaker Street, Derby, are charged with two counts each. Razwan Javed, of Wilfred Street, Derby, and Kabir Ahmed, of Madeley Street, Derby, are charged with one count each.

The Crown says Ali was charged with four counts because he was the person responsible for the distribution of the leaflets.

Each of the five men admits distributing the leaflets, but Cheema said they would probably put forward various lines of defence.

In police interviews, she told the court, Ahmed had said he did not feel that the views expressed in The Death Penalty? leaflet – which suggested three different ways to murder gay people – were wrong and simply expressed what Islam says about homosexuality, adding that it was his duty as a Muslim to condemn it.

Razwan Javed, Cheema said, had also admitted distributing the leaflets but said it was only to raise awareness about what Islam says about homosexuality and not to frighten or threaten anyone.

Cheema said Ali had approached police a few weeks before a planned Gay Pride parade in Derby to discuss a counter-protest by members of the Muslim community, and was advised that any placards, flyers or speeches that were made should be carefully worded to avoid committing a criminal offence.

He had shown police an A4 page of slogans intended for use on placards with some crossed out by his solicitor and asked police to check out the remaining ones, she said.

Cheema said they contained slogans such as: "Stay gay and you will pay," and "Adam and Eve, not Steve".

His request for permission for a counter-protest was eventually refused because he had not applied to the council with enough time before the parade.

"You will have to assess quite how much Mr Ali wanted to carry out a lawful and legal protest and quite how much of what he wanted was a shield he could hide behind from the consequences of what he really hoped to achieve," she said.

The trial continues.