A judge prevented the BBC from broadcasting two documentaries about last summer's riots without having watched the films – and later prevented the media from reporting his injunction.

Mr Justice Flaux, who was presiding over the murder trial of eight men who were acquitted at Birmingham crown court on Thursday, made the injunction on the grounds that the film raised issues which "echoed" arguments put before his jury.

He used an unusual power under section 45 of the Senior Courts Act 1981, which in some circumstances grants crown court judges the same powers as those used by the high court, to prevent the film from being broadcast.

On Wednesday, the BBC and Guardian and sought to challenge the ruling, on the grounds that the films made no reference to the case being considered by the jury and did not even mention rioting in Birmingham.

They also argued that under section 5 of the Contempt Court Act a publication made as or as part of a discussion in good faith of public affairs or other matters of general public interest "is not to be treated as a contempt of court … if the risk of impediment or prejudice to particular legal proceedings is merely incidental to the discussion".

However, the judge rejected the appeal, saying the films touched on issues related to his case, and if he were to allow the films to be broadcast, jurors could potentially have "social contact" with others who watched the programmes.

He also issued a second order, under section 4 (2) of the Contempt of Court Act 1981, which barred media organisations from reporting the injunction.

However, the end of the trial rendered both orders redundant.

The first documentary in the series The Riots: In their own Words, which had been scheduled for broadcast on Monday at 9pm, was a verbatim drama, based on extracts from anonymous interviews with rioters conducted by the Guardian and London School of Economics study, Reading the Riots.

The script for the film was produced by the award-winning playwright Alecky Blythe and the rioters are played by actors.

The second film, which had been due for broadcast on Wednesday, was a more conventional documentary format, with police officers talking about their experiences policing the riots.

The ruling caused a major headache for BBC executives, who had carefully timed the broadcast of the films to coincide with next month's anniversary of the riots, while trying to avoid a clash Olympics coverage. It is not clear when the films will be shown, although the corporation has said they will be aired "at a later date".

Flaux's ruling initially meant media were unable to report details such as his name, his court, or the case he was presiding over, although it considered possible to report that an order had been made preventing the BBC films from being broadcast.

Later, the media was effectively barred from reporting the issue altogether. The move led to widespread rumour on Twitter, amid concern that a film could be pulled from the BBC's schedule by an unnamed judge without explanation.

Kirsty Hughes, the chief executive of Index on Censorship, described the ruling as "disturbing". "Censoring television programmes is not in any way helpful to our understanding of the important issues and factors underlying the disturbances," she said.

Justice Flaux initially released his injunction on Monday, without having seen either of the films of having any detailed knowledge of their content.

A defence barrister alerted the judge to the films, suggesting that although they may not contain any references to Birmingham, the judge may want to take action out of "an abundance of caution".

The BBC was told about the injunction just hours before the broadcast, and tried unsuccessfully to appeal via telephone conference.

On Wednesday, the BBC made a formal challenge to the ruling, which was supported by counsel from the Guardian.

Rejecting the arguments brought by the media organisations, the judge said that although he had not watched the films, he had read part of the transcripts and seen a two-minute clip on the BBC website.

He added that in the first film, the testimony from rioters in the first programme was similar to allegations raised by prosecution in the trial of the eight men.

He gave the examples of actors talking about the "adrenaline rush" experienced during the riots, taking revenge against police and bricks being thrown at cars – all issues raised during the trial. He said there were also issues in the second film, such as police officers talking about how rioters used BlackBerry Messenger (BBM) to communicate.

The two-part film was "literally littered" with potentially prejudicial commentary that could derail the 12-week trial, Flaux claimed.

In a pointed exchange, counsel for the eight defendants said they would have made an application to discharge the jury if the BBC films had been broadcast as planned on Monday and Wednesday.

"These programmes were potentially extremely prejudicial," Flaux said. "In my very clear judgment the continuation of the order – which, it has rightly been pointed out, is an injunction – that I made on Monday is the only necessary and proportionate remedy.

"If the BBC were to broadcast now, when the jury has already gone out, there would be a serious risk that this trial and the course of justice would be prejudiced."

He repeatedly described the BBC as "irresponsible" for attempting to overturn the order, and described as "complete and utter nonsense" any suggestion he had issued a "worldwide gagging order".

Heather Rogers QC, for the BBC, questioned whether a unilateral ban on the films was necessary and proportionate. She suggested a more reasonable measure would be to warn jurors not to watch the films, but allow them to be broadcast as planned.

However, Flaux dismissed this as "completely unreal", adding that jurors could be alerted to the content of the films through social contact with friends. He said it was "absolutely staggering" that the BBC sought further clarification on the reasons for the ban.

The judge's reasoning behind the ban appeared to suggest that any general reporting of the unrest in England, including references to the mood of rioters, their experiences or their use of social network technologies, was likely to be seen as potentially prejudicial to the trial.

Flaux described the trial as the most high-profile since the disorder last August. He said the interests in ensuring justice "outweigh" the interests in not broadcasting the programme.

A spokesperson for the broadcaster said, "The BBC was of the firm view that as the programmes did not contain any reference to the incident which was the subject of the trial their broadcast could not have affected the trial's outcome."

"As makers of current affairs programmes we felt this was a critical point regarding the freedom of the media to discuss matters that are of general public interest. We were disappointed by the Judge's ruling which prevented the programmes from being broadcast until the jury returned its verdicts. Now that has happened, we are pleased to be able to show the programmes. "