ALMATY: Hour upon hour, day upon day, Omir Bekali and other detainees in far western China's new indoctrination camps had to disavow their Islamic beliefs, criticise themselves and their loved ones and give thanks to the ruling Communist Party. When Bekali, a Kazakh Muslim, refused to follow orders each day, he was forced to stand at a wall for five hours at a time. A week later, he was sent to solitary confinement, where he was deprived of food for 24 hours. After 20 days in the heavily guarded camp, he wanted to kill himself.

"The psychological pressure is enormous, when you have to criticise yourself, denounce your thinking — your own ethnic group," said Bekali, who broke down in tears as he described the camp. "I still think about it every night, until the sun rises. I can't sleep. The thoughts are with me all the time."

Since last spring, Chinese authorities in the heavily Muslim region of Xinjiang have ensnared tens, possibly hundreds of thousands of Muslim Chinese — and even foreign citizens — in mass internment camps. This detention campaign has swept across Xinjiang, a territory half the area of India, leading to what a US commission on China last month said is "the largest mass incarceration of a minority population in the world today."

Chinese officials have largely avoided comment on the camps, but some are quoted in state media as saying that ideological changes are needed to fight separatism and Islamic extremism. Radical Muslim Uighurs have killed hundreds in recent years, and China considers the region a threat to peace in a country where the majority is Han Chinese.

The internment program aims to rewire the political thinking of detainees, erase their Islamic beliefs and reshape their very identities. The camps have expanded rapidly over the past year, with almost no judicial process or legal paperwork. Detainees who most vigorously criticize the people and things they love are rewarded, and those who refuse to do so are punished with solitary confinement, beatings and food deprivation.

The recollections of Bekali, a heavyset and quiet 42-year-old, offer what appears to be the most detailed account yet of life inside so-called re-education camps. The Associated Press also conducted rare interviews with three other former internees and a former instructor in other centers who corroborated Bekali's depiction. Most spoke on condition of anonymity to protect their families in China.

Bekali's case stands out because he was a foreign citizen, of Kazakhstan, who was seized by China's security agencies and detained for eight months last year without recourse. Although some details are impossible to verify, two Kazakh diplomats confirmed he was held for seven months and then sent to re-education.

The detention program is a hallmark of China's emboldened state security apparatus under the deeply nationalistic, hard-line rule of President Xi Jinping. It is partly rooted in the ancient Chinese belief in transformation through education — taken once before to terrifying extremes during the mass thought reform campaigns of Mao Zedong, the Chinese leader sometimes channelled by Xi.

"Cultural cleansing is Beijing's attempt to find a final solution to the Xinjiang problem," said James Millward, a China historian at Georgetown University.

Rian Thum, a professor at Loyola University in New Orleans, said China's re-education system echoes some of the worst human rights violations in history.

"The closest analogue is maybe the Cultural Revolution in that this will leave long-term, psychological effects," Thum said. "This will create a multi-generational trauma from which many people will never recover."

Asked to comment on the camps, China's Foreign Ministry said it "had not heard" of the situation. When asked why non-Chinese had been detained, it said the Chinese government protects the rights of foreigners in China and they should also be law-abiding. Chinese officials in Xinjiang did not respond to requests for comment.

However, bits and pieces from state media and journals show the confidence Xinjiang officials hold in methods that they say work well to curb religious extremism. China's top prosecutor, Zhang Jun, urged Xinjiang's authorities this month to extensively expand what the government calls the "transformation through education" drive in an "all-out effort" to fight separatism and extremism.

In a June 2017 paper published by a state-run journal, a researcher from Xinjiang's Communist Party School reported that most of 588 surveyed participants did not know what they had done wrong when they were sent to re-education. But by the time they were released, nearly all — 98.8 percent— had learned their mistakes, the paper said.

Transformation through education, the researcher concluded, "is a permanent cure."

"PEOPLE'S WAR ON TERROR"

On the chilly morning of March 23, 2017, Bekali drove up to the Chinese border from his home in Almaty, Kazakhstan, got a stamp in his Kazakh passport and crossed over for a work trip, not quite grasping the extraordinary circumstances he was stepping into.

Bekali was born in China in 1976 to Kazakh and Uighur parents, moved to Kazakhstan in 2006 and received citizenship three years later. He was out of China in 2016, when authorities sharply escalated a "People's War on Terror" to root out what the government called religious extremism and separatism in Xinjiang, a large Chinese territory bordering Pakistan and several Central Asian states, including Kazakhstan.

The Xinjiang he returned to was unrecognizable. All-encompassing, data-driven surveillance tracked residents in a region with around 12 million Muslims, including ethnic Uighurs and Kazakhs. Viewing a foreign website, taking phone calls from relatives abroad, praying regularly or growing a beard could land one in a political indoctrination camp, or prison, or both.

The new internment system was shrouded in secrecy, with no publicly available data on the numbers of camps or detainees. The US State Department estimates those being held are "at the very least in the tens of thousands." A Turkey-based TV station run by Xinjiang exiles said almost 900,000 were detained, citing leaked government documents.

Adrian Zenz, a researcher at the European School of Culture and Theology, puts the number between several hundreds of thousands and just over 1 million. Government bids and recruitment ads studied by Zenz suggest that the camps have cost more than $100 million since 2016, and construction is ongoing.

Bekali knew none of this when he visited his parents on March 25. He passed police checkpoints and handed over his decade-old Chinese identity card.

The next day, five armed policemen showed up at Bekali's parents' doorstep and took him away. They said there was a warrant for his arrest in Karamay, a frontier oil town where he lived a decade earlier. He couldn't call his parents or a lawyer, the police added, because his case was "special."

Bekali was held in a cell, incommunicado, for a week, and then was driven 500 miles (804 kilometres) to Karamay's Baijiantan District public security office.

There, they strapped him into a "tiger chair," a device that clamped down his wrists and ankles. They also hung him by his wrists against a barred wall, just high enough so he would feel excruciating pressure in his shoulder unless he stood on the balls of his bare feet. They interrogated him about his work with a tourist agency inviting Chinese to apply for Kazakh tourist visas, which they claimed was a way to help Chinese Muslims escape.

"I haven't committed any crimes!" Bekali yelled.

They asked for days what he knew about two dozen prominent ethnic Uighur activists and businessmen in Kazakhstan. Exhausted and aching, Bekali coughed up what he knew about a few names he recognized.

The police then sent Bekali to a 10- by 10-meter (32- by 32-foot) cell in the prison with 17 others, their feet chained to the posts of two large beds. Some wore dark blue uniforms, while others wore orange for political crimes. Bekali was given orange.

In mid-July, three months after his arrest, Bekali received a visit from Kazakh diplomats. China's mass detention of ethnic Kazakhs — and even Kazakh citizens — has begun to make waves in the Central Asian country of 18 million. Kazakh officials say China detained 10 Kazakh citizens and hundreds of ethnic Kazakh Chinese in Xinjiang over the past year, though they were released in late April following a visit by a Kazakh deputy foreign minister.

Four months after the visit, Bekali was taken out of his cell and handed a release paper.

But he was not yet free.