NEW YORK — The leader of a secretive group accused of coercing female followers into having sex and getting branded with his initials faced a federal judge Friday who ordered him to remain behind bars weeks after his arrest in Mexico.

Keith Raniere responded “Yes, your honor” when Judge Steven L. Tiscione asked whether he understood the charges the FBI filed against him — sex trafficking and forced labor conspiracy.

The 57-year-old Raniere, who sold himself as a self-improvement guru to the stars, was brought to the United States from Mexico on March 26. He did not enter a plea during the Brooklyn federal court hearing. His attorney said no bail is currently being requested, and issued a permanent order of detention.

“I’m feeling safe for the first time in years. I feel free,” said Raniere’s ex-girlfriend, Barbara Boucher, who left him in 2009 and said she was “stalked” by members of his group, called NXIVM, pronounced Nexium.

She said that seeing him for the first time in nine years as he walked quietly into the courtroom wearing a pale green jumpsuit, she “felt a lot of grief, like a death, because I deeply loved this man.”

“This man was brilliant and could have done a lot of good, if it weren’t for his dark side,” said Boucher.

In March, federal authorities raided an upstate New York residence near Albany connected to NXIVM and Raniere. The cult-like organization also ran programs in Mexico.

Raniere’s followers included Clare and Sara Bronfman, heiresses to the Seagram liquor fortune, and Emiliano Salinas Occelli, son of former Mexican president Carlos Salinas de Gortari, who with a business partner controlled the Raniere-linked Executive Success Programs in Mexico.

On Thursday, they cut all ties to their onetime leader.

“With this decision, we end our activities and collaboration with the brand ESP Mexico from today onward, as well as our professional and economic relationship with the United States’ NXIVM and its related entities,” they wrote in Spanish on their website.

Another of his disciples-turned-sex-slave was television actress Allison Mack, who starred in The CW network’s “Smallville,”

Founded in 1998, NXIVM promoted Raniere’s teachings as a kind of mystical, executive coaching designed to help people get the most out of life. Enrollees in its Executive Success Programs paid handsomely for his advice, but the organization also drew criticism from people who likened it to a cult.

Last year, the accusations took a new twist, with women who were part of a NXIVM subgroup coming forward to say that they had been physically branded near their pelvises with a surgical tool against their will.