NEW YORK — Self-help guru Keith Raniere was a coward during his arrest last year in Mexico on a U.S. sex-trafficking charge and a bully when dealing with a follower who failed to adhere to his twisted code of ethics, a witness testified Tuesday at Raniere's New York City trial.

The follower was confined to a bedroom for two years, the witness said, despite passing a note that begged: "Let me out. I'm coming undone."

The harsh portrait of Raniere was provided by Lauren Salzman, a former member of his inner-circle in a group called NXIVM who's pleaded guilty and is cooperating with the government.

Salzman, 42, was recruited, along with TV actress Allison Mack and others, for a secret society within NXIVM of women who prosecutors say were brainwashed by Raniere's teachings, branded with his initials and pressured into having sex with him.

Mack, a star of the TV series "Smallville," has also pleaded guilty, but it's unclear if she'll testify.

Defense lawyers have insisted any contact Raniere had with the women was consensual.

Salzman told the jury on Tuesday that Raniere — spooked by mounting news reports that the sorority was under investigation — went to Mexico with Salzman, Mack and others to try to reconstitute the group there. When Mexican authorities broke down his door at a villa in Puerta Vallarta to grab him, Salzman was there and tried to stand up to them while he hid in a closet, she said.

The scene made clear that while she had been programmed to put Raniere first in times of trouble, "Keith would choose Keith," she said.

The witness also detailed how Raniere groomed as followers a family from Mexico with three daughters. According to prosecutors, he sexually exploited all three — the youngest starting at age 15.

The middle sister, whose full name has been withheld by prosecutors, had a falling out with Raniere around 2010, Salzman said. He assigned Salzman to rehabilitate the victim by ordering her into a bedroom in her family's Albany-area home — with only a mattress and pen and paper — until she made amends to him in handwritten letters, she said.

What was expected to last no more than 10 days stretched into nearly two years when Raniere refused to forgive the victim and allow her back into the NXIVM community, the witness said. Her family finally returned her to Mexico and cut off support.

"I was unkind," said Salzman, weeping as recalled her role in the episode. "I think it's horrendous. Of all the things I did in this case, this was the worst."