A senior British Muslim last night defended West Midlands Police from fierce criticism after it attempted to discredit a TV documentary exposing Islamic extremism in Birmingham.

The force was accused by Channel 4 bosses of "staggering naivety" for referring an episode of the flagship documentary Dispatches to media watchdog Ofcom.

Police claimed the programme, Under-cover Mosque, misrepresented the views of Muslim clerics in the city and undermined community cohesion and safety. But Ofcom yesterday ruled the documentary was "a legitimate investigation" and "found no evidence that the broadcaster had misled the audience".

Channel 4 bosses and opposition politicians condemned West Midlands Police, with the broadcaster describing the force's actions as "perverse" and giving, in some people's eyes, "legitimacy to people preaching a message of hate".

However, Tahir Alam, assistant secretary for the Muslim Council of Britain, said: "I think the police acted responsibly by investigating within the current context.

"There is an unhealthy focus on the Muslim community and coverage has been very unfriendly. It was not the first such programme to pursue a similar line of inquiry. These kind of irresponsible programmes damage community relations. Yes, there is freedom of the press, but that is no reason to target a select community in this way."

Undercover Mosque was broadcast in January. It featured undercover recordings made in a number of Birmingham mosques alleged to be homophobic, anti-Semitic, sexist and condemnatory of non-Muslims.

Statements from preachers included: "take that homosexual and throw him off the mountain" and "whoever changes his religion from Al Islam to anything else - kill him in the Islamic state".

Police initially launched an investigation into whether criminal offences had been committed, but after finding no evidence turned on the programme makers.

The force believed the views of people teaching and preaching at the mosques had been misrepresented through editing "sufficient to undermine community cohesion".

After being advised by the Crown Prosecution Service that any conviction was unlikely, police referred the programme - which also gained 364 complaints from viewers - to Ofcom.

The force last night said it accepted Ofcom's ruling, but maintained it was right to complain to the regulator.

Assistant Chief Constable David Shaw said: "We don't feel our view has changed, or will, for part of that programme could cause concern in some parts of the community." He added the police defended the "vital" right of journalists to investigate. "Nothing that we have done should be construed as saying that shouldn't take place. But there are some limits to that."

Douglas Sharp, a lecturer in criminology at Birmingham City University and a former police chief superintendent, claimed the force had been left with "egg on their faces". "I think it is a bit of a cock-up. Someone associated with the original investigation got hot under the collar and referred this complaint to Ofcom without really thinking it through," he said.

The chorus of criticism was led by Andy Duncan, chief executive of Channel 4 who said there had been "a concerted effort to discredit" the programme.

Kevin Sutcliffe, Channel 4's deputy head of news and current affairs, said police had, in the eyes of some, given "legitimacy to people preaching a message of hate to British citizens and damaged the reputations of those involved in producing and broadcasting the programme".

And a spokesman for Channel 4 added the force had "portrayed staggering naivety about the process of television production".

Shadow home secretary David Davis said: "Once they were clear that no criminal offence had been committed, it was a serious misjudgment to continue to pursue the editorial team and risked impeding freedom of speech."