Richard Stringellow told a jury how he "froze" as he felt "something cold and hard" pressed against his neck during the attack by Daniel Sonnex.
Other prison officers said Sonnex was shouting, foaming at the mouth, and chanting in Arabic, Reading Crown Court was told.
Sonnex, serving life with a minimum term of 40 years for the two murders, jumped on Mr Stringfellow's back and held a vegetable knife to his throat, jurors heard.
The officer said: "I knew his history and I had seen him previously with the knife. I seriously believed that I was going to die that instant, if not then, then shortly after that."
His ordeal came to an end when his colleagues intervened and restrained Sonnex, Mr Stringfellow said. He suffered superficial cuts to his neck and a swollen right knee but no serious injuries.
Sonnex denies a charge of false imprisonment of the officer in which he was said to have "assaulted and unlawfully and injuriously imprisoned and detained" him against his will, as well as threatening to kill him.
The 27-year-old, formerly of Deptford, south east London, is now being held at high-security psychiatric hospital Broadmoor, and appeared in the dock flanked by five male nurses. He wore sunglasses in court due to a medical condition.
Jurors heard that Sonnex was serving life for the two murders at HMP Long Lartin near Evesham, Worcs, at the time of the attack in June 2010.
He had previous convictions for wounding with intent and robbery.
Peter Grice, prosecuting, said all the offences had involved the use of a knife, while Sonnex had also attacked prison officers twice during 2009.
The attack on Mr Stringfellow took place after shelves and an element had been removed from a fridge used by prisoners. The officer spotted them in the exercise and picked them up, and returned to the wing, Mr Grice said.
"As he did so he was followed by the defendant," Mr Grice said. "What happened next is the defendant jumped on Mr Stringfellow's back.
"He put his arms around his neck and he put a knife, a vegetable knife, to his throat.
"As he did he shouted at Mr Stringfellow, 'I have got a knife, I'm going to slit your f****** throat'.
"Put very bluntly, you will hear from Mr Stringfellow, he thought his number was up," the prosecutor said.
"He was aware of the defendant's previous convictions and he thought he was going to die."
Mr Grice said Sonnex also shouted at prison staff: "This is a hostage situation, don't come any closer."
The incident ended with the officer falling to his knees, and fellow prison staff "disarming and overpowering" Sonnex, the court heard.
A search of the convicted killer found a piece of the fridge fashioned into a hook in his shorts pocket, Mr Grice said.
Describing his ordeal, Mr Stringfellow told the court: "I just felt someone jump on to my back, put their arms around my throat tightly," Mr Stringfellow told the court.
"I felt arms round my neck and shoulders restricting my movement.
"The next thing I was aware of was something cold and hard being pressed against my throat and Mr Sonnex shouting angrily out that he had a knife and he was going to slit my f****** throat.
"As far as I can remember I sort of froze, I didn't feel able to move."
Joe Stone, representing Sonnex, said in cross-examination of Mr Stringfellow: "I don't dispute that Mr Sonnex jumped on your back and I don't dispute that he held a knife to your throat."
He asked the prison officer if he had heard Sonnex shout - after he was restrained by four other officers: "Send me to paradise, brothers help me."
Mr Stringfellow replied: "There was a lot of shouting and noise going on, from prisoners and possibly staff."
Another officer, Andrea d'Arienzo said: "I heard him shout, 'I am here for 40 years, kill me now, take me to the promised land"'.
Senior prison officer Alexis Wood described Sonnex as "shouting and screaming, he was foaming at the mouth, his eyes were glazed".
"He was shouting, ' I want to die, show me paradise, you're all going to die'.
"He was also calling on Allah and his Muslim brothers."