A former close friend of Robert Durst admitted in court Thursday the millionaire heir confessed to killing their mutual best friend.

Nathan Chavin testified in Los Angeles that Durst told him in 2014 that he killed Susan Berman.

WOMAN CHAINED IN METAL BOX SAYS CAPTOR BRAGGED ABOUT DOZENS OF VICTIMS

Chavin says Durst said he had to. He said: "It was her or me, I had no choice."

Chavin, who became emotional while testifying, said he still has warm feelings for Durst.

FRIEND OF SAN BERNARDINO ATTACKER PLEADS GUILTY TO PROVIDING GUNS

Durst has pleaded not guilty to murder in the 2000 execution-style shooting of Berman inside her Los Angeles home.

Chavin said the conversation came at the end of a dinner Durst arranged to discuss Berman and the disappearance of his first wife.

Chavin also said that Durst's wife told him she was afraid of her husband before she disappeared.

Chavin is a New York advertising executive who was a longtime friend of Durst and his wife. He was also a friend of Berman, whom Durst is charged with killing.

On Wednesday, Chavin described watching Durst's marriage deteriorate before his wife, who went by Kathie, mysteriously disappeared in 1982.

Kathie Durst had confided in Chavin with her worries about her husband, but didn't discuss any violence, according to Chavin.

"She said she was afraid of him," Chavin said. "She never said he hurt her."

Robert Durst is not charged in Kathie Durst's disappearance, but prosecutors contend that he killed his best friend Berman in 2000 because she was going to talk to police about the case.

Chavin testified that he did not think Durst was responsible for his wife's disappearance at the time.

Before he took the stand, Chavin's identity had been kept a secret, and he entered the courtroom through a back door with a personal security detail.

Prosecutors have suggested that with Durst's estimated $100 million fortune, he could have witnesses knocked off. The defense said that suggestion is absurd and have pointed to Durst's frail condition and the fact he's in jail where his phone conversations are recorded.

But the judge allowed Chavin to testify in a rare proceeding to record testimony from a few elderly witnesses and those who fear for their safety and may not be alive to testify at trial. Durst has yet to even be ordered to stand trial.

Because Berman's murder trial is not likely to begin until next year, prosecutors asked that Chavin testify early out of fear he might be killed before trial, the Los Angeles Times reported.

Chavin, 72, said he once considered Durst his best friend.

He told of two violent incidents Durst described to him, including one that involved kicking a man in the head who had flirted with his wife.

"The guy pissed him off," Chavin said and he noted that Durst never showed any regret for the incident or distress after being sued.

In another incident, Durst said he had run over a female police officer in the San Francisco Bay Area while creeping through traffic.

Chavin asked why he wasn't in jail.

Durst replied: "What's she going to do, go to her superiors and say, `He ran over me at 1 mph?"' Chavin said. "I think he did it in a prankish way."

Fox News' Laura Prabucki in Los Angeles and The Associated Press contributed to this report.