A prisoner accused of killing a fellow inmate in their shared cell told police "I murdered him because he's a sex offender", a court has heard.
John Westland, 29, supposedly made the comments a day after the body of Liam Deane was found by officers at HMP Leeds.
Prosecutors at Leeds Crown Court described how Mr Deane, 22, was attacked with fragments of glass from a smashed aftershave bottle and was asphyxiated by pressure applied to his head and face.
Jurors were told the deceased and Westland shared a cell in F-wing of the prison in Armley, and were both locked in for the night at 5pm on November 11 2017.
During his opening speech, Peter Moulson QC, prosecuting, said: "The following morning, Mr Deane was found dead because someone, say the prosecution, had assaulted him.
"Obviously, there was only one candidate."
The court heard statements from prison officers who claimed that Westland had triggered an alarm system at around 5.30am on November 12, which prompted on-duty personnel to rush to the scene.
A "code red" situation was declared after a pale-looking Mr Deane was found covered in blood, and he was declared dead around half an hour later.
Asked about Westland's demeanour as a nurse tried to treat his cellmate, one prison officer said he had appeared "agitated" and "unable to sit still", going to the toilet four times and attempting to wash his hands despite being told not to.
A colleague claimed the defendant was taken to a secure cell where he grew frustrated at being given ill-fitting prison-issue clothing.
When the guard told him to "lose the attitude", Westland supposedly responded: "You lose your attitude, you should see what happened in that cell."
The officer added that the defendant's manner meant he took it "as a threat".
Mr Moulson told jurors that although Mr Deane had taken a drug known as "spice", this was not the cause of death, and Westland's fingerprints were found on the shards of glass found in the cell.
As he was charged in connection with the death, the defendant is alleged to have told police officers he had committed the crime because the deceased "was a sex offender".
Jurors have not been told why either man was in prison at the time.
Westland denies murder and, according to Mr Moulson, claims that self-inflicted injuries and a drug overdose were the cause of death.
The trial, which is expected to last a week, continues.