An episode of BBC One drama Silent Witness that featured scenes of sexual violence broke the corporation's guidelines, the BBC Trust has ruled.
The episode culminated in a scene featuring a prison officer attacking an inmate in a toilet cubicle.
More than 600 people complained to the BBC about the programme, which was broadcast last April.
The trust said the scenes were "too explicit for this series... in the first hour after the watershed".
It was responding to a complaint from a viewer who had tuned in to watch the BBC's News at Ten but was unexpectedly confronted with the scenes after the drama overran by 90 seconds.
The viewer said he found the scenes "extremely upsetting" and "thoroughly nasty".
At the time, the episode carried a pre-programme announcement warning viewers of violent and upsetting scenes.
However, the viewer said people tuning in for the evening news could not have been expected to have been watching earlier to see the warning.
The scene in question - depicted as a flashback - featured a character lying in a pool of blood while his attacker was seen holding a bloodied stick.
In its ruling, the trust said that although the actual attack was not shown, "viewers were left in no doubt that an act of sexual violence was being carried out".
It said that while the drama, now in its 15th series, was known to investigate the aftermaths of violent crimes, this episode was "noticeably darker in tone".
As there were a significant number of complaints, it concluded that the scenes were in breach of the guidelines on harm and offence as they "exceeded audience expectations for this series as they depicted a sadistic method of inflicting pain, injury and death".
In its response, BBC Vision - the department responsible for BBC drama - said the overrunning of programmes was a regular occurrence.
"Silent Witness overran the billed finish time by 90 seconds and the news was two minutes late," it said.
"This is all well within the parameters of a 'normal' programme junction and would not have triggered any extra editorial scrutiny beyond that carried out for the original schedule."
The trust noted that although compliance procedures had been followed for the episode, it felt "the wrong editorial judgement had been made on this occasion and this episode was not suitable for broadcast".
It offered an apology to viewers who had complained and to those who had tuned in for the news and had "been taken unawares by the final scenes".