Reza Zarrab, the star prosecution witness in the trial of a Turkish banker charged in a billion-dollar scheme to violate United States sanctions on Iran, was in his seventh day of testimony in Manhattan this past week when he revealed what he called a jailhouse attempt to kill him.

He had pleaded guilty to a conspiracy to smuggle gold for oil, and on Thursday, a prosecutor was leading him through some of the risks he had taken by deciding to cooperate with the government in the case.

While he was being held in a federal detention center in Brooklyn, Mr. Zarrab told the jury, an inmate pulled a knife and said he had been instructed to kill him.

“I was about to lose my life,” Mr. Zarrab testified. “He said that he had heard that I was cooperating — that’s why he was doing it.” He was removed from the Brooklyn jail and placed in the F.B.I.’s custody.