A 25-year-old man has pleaded not guilty to the murder of fellow prisoner Gary Douche in Mountjoy Prison.
Stephen Egan of Belcamp Crescent, Coolock, Dublin, denied the murder of Mr Douche in a holding cell on 1 August 2006.
The jury will have to decide whether he is guilty of murder, or guilty of manslaughter on the grounds of diminished responsibility.
Mr Egan told gardaí he attacked Mr Douche in a ten-minute frenzy.
He punched him three times in the jaw, kicked him three times in the head area and stamped on him.
Mr Douche and five other men were held overnight in the cell with Mr Egan.
The next morning, prison officers discovered Mr Douche's badly beaten body. His face had been smeared with excrement.
He was taken to the Mater Hospital but died as a result of blunt force trauma to the head and neck.
At the Central Criminal Court today, Prosecution counsel Anthony Sammon told the jury that Mr Egan had a long history of psychiatric problems.
He said the jury would have little to decide in this case and their main focus would be the state of mind of the accused at the time of the attack.
Seven admissions were read to the court by defence counsel John Aylmar. In these, Mr Egan admitted the unlawful killing.
In statements to gardaí, the accused said he had 'heard things in his head' and attacked Gary Douche because in his mind he was a rapist and had done things to his mother and sister.
Defence counsel John Aylmar said the accused admitted that his claims that the deceased man was a sexual offender were illusionary and borne out of psychotic illness.
It is the State's case that Mr Egan was suffering from a mental disorder that diminished his responsibility for the attack on Mr Douche.
Evidence about his mental state will be given by a forensic psychiatrist tomorrow.