The Indonesian anti-corruption investigators began hunting for the powerful local official after they caught two of his aides taking a $40,000 bribe.

Their six-month investigation led them to a sprawling estate in North Sumatra, where they made a shocking discovery: 65 men locked in two cages.

The captives, investigators learned, had been imprisoned under the guise of a drug rehabilitation program and forced to work as slaves at a palm plantation and palm oil factory owned by the official, Terbit Rencana Perangin-angin, and his family.

Dozens of victims told the authorities that they received no treatment for their addiction.

“This was not rehab. This was jail,” said a former captive who goes by Bambang and assisted two government investigations. “They treated us like animals. We were just hopeless there.”

The corruption investigators arrested Mr. Perangin-angin, 50, on bribery charges in January 2022, days after the cages were discovered. He was tried and convicted of bribery in Jakarta, the capital, and sentenced to seven and a half years in October. The police seized his factory and he was stripped of his elected post as regent, similar to the leader of a county in the United States.

But Mr. Perangin-angin has not been charged or tried on any charges related to the men who were found caged on his property.

The case highlights Indonesia’s dismal human rights record and the rampant corruption that flourishes at the regional level, where governors, regents and big-city mayors are often called “little kings.”

An investigation by the North Sumatra provincial police found that 656 men and teenage boys had been imprisoned in cages on Mr. Perangin-angin’s land during the decade before his arrest. They were usually held for about 18 months before being released.

Most of the victims were forced to work at the factory or on the plantation, often alongside paid workers. Many were tortured, whipped, burned and sexually assaulted. Six prisoners died, including at least three who were tortured to death, according to Indonesia’s National Commission on Human Rights.

Former captives also cleaned Mr. Perangin-angin’s mansion, washed his vehicles and fed his 200 cows. The captives were easily recognizable by their closely cropped hair.

“The regent didn’t want to spend money to hire workers and so they enslaved us by using rehab as the excuse,” said Ardi, 18, who was imprisoned at 15 and ordered to sweep floors at the regent’s mansion. “But they never gave us any treatment. It was basically a scam.”

Ardi is one of four victims under witness protection who agreed to speak to The New York Times on the condition that they not be identified by their full names for fear of retaliation.

Although the cages were an open secret in the community, local police and officials never intervened because Mr. Perangin-angin was seen as all powerful in Langkat Regency, the jurisdiction where the cages were found. Some police officers and soldiers even helped guard or torture the men, victims and the authorities said.

“No one could stop him,” said Rianto Wicaksono, an agent with Indonesia’s Victim and Witness Protection Agency, an independent government agency that safeguards victims and witnesses of crime. “The police in the area were under his command. No one was brave enough to go up against him.”

While Mr. Perangin-angin has avoided charges in the slavery case thus far, 13 of some 60 men identified by the victims have been prosecuted for their role in the operation.

Victims who testified about their mistreatment say they are frustrated by the leniency that the police and courts have shown. None of the accused has faced more than a single charge, and the longest sentence handed down was three years.

A military court convicted five soldiers of torturing prisoners and sentenced them to a year or less. Five police officers — including Mr. Perangin-angin’s brother-in-law — were demoted but not charged.

Mr. Perangin-angin’s son, Dewa Rencana Perangin-angin, 25, was convicted in November of torturing a man to death and sentenced to 19 months. Mr. Perangin-angin has denied any knowledge of the operation. He and his son did not respond to interview requests or written questions submitted through their lawyer.

The push for prosecutions has been led by the witness protection agency and the national human rights group, Kontras, which both conducted their own investigations and urged the police to do more. The witness protection agency estimated that Mr. Perangin-angin’s businesses made $12 million from the captives’ unpaid labor.

“It is no surprise that the legal process would go easy on all the culprits,” said Rahmat Muhammad, Kontras’s North Sumatra director. “It is because the regent is wealthy and has a powerful network.”

As the top elected official of Langkat Regency, Mr. Perangin-angin enforced his will through violence, intimidation and political connections. He headed the locally dominant political party, as well as a politically influential youth organization known for extortion. Relatives held key leadership positions, including his sister, the regency parliament’s speaker.

All four victims interviewed by The Times testified against the handful of perpetrators who have been brought to trial. The witnesses say they fear for their safety when they see men who guarded and tortured them roaming free.

Mr. Perangin-angin’s walled estate stands among the small open-air shops and one-story houses that line the main road of Raja Tengah, a small village in Langkat Regency.

Illegal drugs, especially meth, plague the region. Many families welcomed the offer of free drug treatment on the estate, enrolling their children and releasing the program from responsibility for death or injury.

Despite the program’s reputation for harsh treatment, many in the community supported the effort to get addicts off the streets. Mr. Perangin-angin publicly promoted the drug rehabilitation program in speeches and on a government YouTube channel.

The two cages, built by prisoners in 2016 to replace an earlier cage, sit side by side, half-hidden at the edge of the palm plantation. With bars like a jail, each cell had one primitive toilet for 30 men or more.

Men who were caught after escaping received brutal punishment. Roni, 25, said a guard lit his pubic hair with a match and burned the tip of his penis with a cigarette after he was recaptured.

The guard then ordered Roni and another escapee to sodomize each other. He said they simulated the act while the guard recorded a video. Roni said he gave the police the names of the guard and 10 others, but none have been arrested.

He has since seen the guard several times in the village.

Sangap Surbakti, a lawyer who previously represented Mr. Perangin-angin, said that his client was aware of the cages because he sometimes went swimming nearby, but that he did not know that men were imprisoned, tortured and forced to work at his properties.

“He just had bad luck because the cages were located near his house,” the lawyer said. “He knew about the cages, but he did not know what happened in there.”

Mr. Surbakti said the existence of the cages was well known to provincial and regency police chiefs and anti-narcotics officials.

“Mr. Perangin-angin just focused on the business,” he said. “He did not even know at the time that these men were transported to the factory.”

Mei Abeto Harahap, the chief prosecutor, said the police have not found enough evidence to support human trafficking charges against Mr. Perangin-angin and others who have not faced trial. “We know it happened, but the police didn’t submit the documents for these particular cases,” he said.

Hadi Wahyudi, a spokesman for the North Sumatra police, defended the thoroughness of the police investigation and said that the police went to great lengths to find potential witnesses to crimes that date back many years.

Bambang, 31, said his parents sent him to rehab at Mr. Perangin-angin’s estate in early 2021 because of his meth addiction. The guards accused him of lying about his source of drugs when he arrived and whipped him repeatedly with a compressor hose, he said. He was given coffee grounds to put on his wounds and, after his recovery, put to work.

Eventually, he said, his captors designated him a “cage-free man.” He was given a key to his enclosure and ordered to supervise other men. His relative freedom allowed him to witness many instances of torture and a killing, he said.

When Sarianto Ginting arrived on the estate for drug treatment in mid-2021, Dewa Perangin-angin, the regent’s son, interrogated him, Bambang said.

When Mr. Ginting insisted he did not use drugs and only drank, Dewa Perangin-angin beat him with a piece of wood and whipped him with a compressor hose, Bambang said.

“He had this excitement seeing people being tortured,” said Sueb, 34, another victim, describing Dewa Perangin-angin. “When he tortured people himself, it was out of control.”

Despite the man’s injuries, Dewa Perangin-angin ordered Mr. Ginting to bathe in a nearby pond and told guards to push him in, Bambang said. The second time Mr. Ginting went under, he did not come up.

Bambang, who helped recover Mr. Ginting’s body from the pond, said he refused an offer of a car and $33,000 — a huge sum in the village — not to testify against the Perangin-angins. Dewa Perangin-angin and another man were convicted of torturing Mr. Ginting to death.

Dewa Perangin-angin was quietly released after serving half his 19-month sentence. A video showed him smiling and dancing at a wedding this year.

Dera Menra Sijabat contributed reporting.