Brusthom Ziamani, 25, and Baz Macaulay Hockton, 26, convicted of trying to murder a prison officer in Whitemoor prison in eastern England were handed life sentences.
The two wore fake suicide belts and shouted “Allahu Akbar” (God is greater) as they launched the attack in January this year.
The pair targeted officer Neil Trundle with makeshift bladed weapons and blows, and also injured another officer and a nurse who intervened in the maximum security facility.
The judge at London’s Old Bailey court hearing the case on Thursday(8) decided it had “a terrorist connection”, resulting in heavier sentences, London’s Metropolitan Police said.
Its counter-terrorism branch investigated the offences, which are believed to be the first acts of terrorism in a British jail outside Northern Ireland.
“This was a calculated and horrific attack by two very dangerous prisoners who had one aim — to try and murder prison staff,” Richard Smith, head of the Met unit, said.
“Our investigation showed they were motivated to carry out this attack by their extreme ideology.”
Ziamani received a life sentence with a minimum term of 21 years for attempted murder, as well as two years for actual bodily harm against the nurse and four months for common assault against the other officer.
The terms will all run concurrently.
He is already five years into a 19-year sentence for a 2014 terror plot to behead a soldier inspired by the high-profile murder of Fusilier Lee Rigby.
Hockton, a Muslim convert who was radicalised in jail, got a minimum term of 23 years imprisonment for the attempted murder.
He also faces 10 years for another assault at a different prison in 2019, which will run concurrently.
Passing sentence, the judge said the duo had been “inspired by extremist beliefs” and that their “twisted view of Islam” must change before they are ever released.
There has been a sharp increase in prisoners convicted of terrorism-related offences, sparking growing concerns that other inmates may become radicalised.
The government says it has trained around 20,000 staff in extremism awareness training, and employs multi-faith chaplaincy teams in all prisons.
It has also opened two so-called Separation Centres where individuals considered to pose the biggest risk are kept away from the main prison population.