Brusthom Ziamani, 25, denied that the incident at HMP Whitemoor in January was a terror attack or that he and a fellow inmate wanted to kill their victim.
He and Baz Hockton, 26, are accused of attempting to murder a prison officer on 9 January with homemade weapons, while allegedly shouting “Allahu akbar” and wearing fake bomb vests.
Giving evidence at the Old Bailey on Thursday, Mr Ziamani said he had made three complaints to prison officials about his treatment, alleging that his Quran had been left on the floor during a prison search and derogatory remarks were made about his Islamic clothing by officers.
He told jurors the “last straw” was when he was told he could not send a photograph of himself to his parents because he was a terrorist prisoner.
“I decided that I want to come out this jail, I can’t stay here no longer,” 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.”
Mr Ziamani, who had been jailed in 2015 after planning to behead a British soldier, said he thought authorities would have to remove him from HMP Whitemoor if he vandalised property or “assaulted a prison officer to a certain seriousness”.
Asked by a defence barrister whether he could have just pushed or shoved a member of staff, the defendant claimed that a “minor altercation” would have resulted in segregation rather than being taken out of the Cambridgeshire jail.
Earlier in the day, the court was told that prison officials had no record of written complaints made by Mr Ziamani.
Jurors have been shown handwritten material from his prison cell that discussed becoming a martyr, but the defendant said the term was “not always about being killed in battle [but] being a righteous person”.
Mr Ziamani denied that his aim was to be killed during the attack at HMP Whitemoor, or that he intended to murder prison officer Neil Trundle or do him “really serious harm”.
The court previously heard that he and Mr Hockton attempted to lure the officer into a cupboard and kill him using improvised weapons.
Mr Trundle shouted for help as the pair started to rain down blows on his head, neck and chest, the jury was told.
The defendants then allegedly attacked two prison officers and a nurse who ran to the aid of their colleague, before being subdued.
Prosecutor Annabel Darlow QC said that when another prison officer tried to intervene, Mr Ziamani opened up his jacket to reveal a fake suicide vest and shouted: “I’ve got a bomb.”
Mr Hockton was also wearing a fake suicide vest, made of wires and plastic cartons covered in fabric.
Ms Darlow said the defendants had “carefully planned and executed” the attack using several weapons they made inside the prison, including a homemade shank, lumps of twisted metal covered with fabric grips and two makeshift “metal stabbing implements”.
She added: “It’s the prosecution’s case that the defendants were motivated to commit the attack by extremist Islamic ideology. It was a terrorist attack.”
The prosecutor said Mr Trundle, a prison officer for 14 years, was known to be “kind and helpful” and had no negative dealings with either defendant in the past.
He was treated in hospital for lacerations to his ear, scalp, shoulder and arm.
The court heard that Mr Ziamani had been jailed for a terror offence and that Mr Hockton had converted to Islam while in prison, and that his faith “had been corrupted into extremism and he had been radicalised”.
On Thursday, Mr Ziamani said his parents were Jehovah’s Witnesses but that he had converted to Islam in April 2014 and was thrown out of his family home.
He said he had been introduced to the religion by members of criminal gangs that he was involved in at the time, and then became part of the al-Muhajiroun Islamist network.
Mr Ziamani said he had met its leader, Anjem Choudary, “three or four times” and had joined the group’s religious study sessions and events.
“When the Islamic State was first declared there were loads of videos coming out so we would sit and watch it,” he added.
The defendant admitted that he obtained an SD card containing “loads and loads of talks from different Islamic scholars” through unofficial channels in prison.
He told the jury that because he could speak Arabic and French, he would translate the videos into English and write transcriptions for other inmates including Mr Hockton.
“I translated it for him to get him to read for personal study,” Mr Ziamani said.
He said he had first met his co-defendant in 2013, outside prison, before they met again at HMP Whitemoor in July last year.
“I was close to him a lot,” Mr Ziamani told jurors, saying they would see each other on a daily basis even while being kept on separate wings.
Mr Ziamani, who left school with no qualifications, said he and Mr Hockton hoped to start a painting and decorating business together after being released from prison.
Both men deny charges of attempted murder but Mr Hockton had admitted an alternative charge of wounding with intent to cause grievous bodily harm.
Mr Ziamani admits charges of assault against another prison officer and a nurse. The trial continues.