A convicted terrorist accused of trying to kill a prison officer in an assault with makeshift weapons said he wanted to be "shipped out" to another jail.
Brusthom Ziamani, 25, and another inmate are accused of attempting to murder Neil Trundle at HMP Whitemoor in Cambridgeshire, on 9 January.
The Old Bailey heard Mr Ziamani had complained to the prison about alleged "anti-Muslim behaviour" at the jail.
He told a jury that, while he accepted assault, he denies attempted murder.
Prosecutors allege Mr Ziamani and fellow inmate Baz Hockton, 26, "lured" Mr Trundle to a store cupboard where they launched the assault with makeshift weapons.
The court has previously heard the pair wore imitation suicide belts and shouted "Allahu Akbar" - "God is greatest" - during the attack.
On Thursday, the court heard Mr Ziamani complained about alleged "anti-Muslim behaviour" on three occasions between 2018 and 2019.
The court was told on one of those occasions, while wearing a shalwar kameez, he said he was told to "lift up your dress and give us a twirl" by an officer and on another had his topi hat compared to a "deflated football".
Joel Bennathan, for Mr Ziamani, asked: "Did there come a time where you decided you needed to do something about Whitemoor?"
Ziamani said he wanted to be "shipped out" to another prison when he was told certain inmates were no longer allowed to send photos to their families who could not visit in late-2019.
He said: "I was disheartened, I was angry, I was emotional.
"All the other stuff I received in the build-up, that was the last straw when they said I couldn't send a photograph to my family, I just couldn't take it any more."
He added: "I decided to attack an officer, it wasn't the right idea to do that but that's how I felt at the time."
Jurors were told an alternative count of inflicting wounding with intent in relation to Mr Trundle was available for Mr Ziamani.
The alternative charge need only be considered if the jury acquit him of attempted murder.
Mr Hockton has already pleaded guilty to that alternative offence, thereby accepting that he intended to cause really serious harm to Mr Trundle, but not accepting that he intended to kill him.
Mr Ziamani has pleaded guilty to assaulting a female prison officer and a nurse who intervened in the attack, the court was told.
The trial continues.