ISTANBUL (AP) — It was mid-afternoon when the Chinese police officers barged into Ali's house set against cotton fields outside the ancient Silk Road trading post of Kashgar. The Uighur farmer and his cowering parents watched them rummage through the house until they found two books in his bedroom — a Quran and a handbook on dealing with interrogations.

Ali knew he was in trouble.

By nightfall the next day, Ali had been tied against a tree and beaten by interrogators trying to force him to say he took part in an ethnic riot that killed dozens in western China. They held burning cigarette tips to Ali's face, deprived him of sleep and offered him only salt water. When he asked for fresh water, they gave it to him — in buckets poured over his head.

That winter night in 2009, Ali recalled years later, would set him on a path that ended on northern Syria's smoldering plains, where he picked up a Kalashnikov rifle under the black flag of jihad and dreamed of launching attacks against the Chinese rulers of his homeland.

Since 2013, thousands of Uighurs, a Turkic-speaking Muslim minority from western China, have traveled to Syria to train with the Uighur militant group Turkistan Islamic Party and fight alongside al-Qaida, playing key roles in several battles. Syrian President Bashar Assad's troops are now clashing with Uighur fighters as the six-year conflict nears its endgame.

But the end of Syria's war may be the beginning of China's worst fears.

"We didn't care how the fighting went or who Assad was," said Ali, who would only give his first name out of a fear of reprisals against his family back home. "We just wanted to learn how to use the weapons and then go back to China."

Uighur militants have killed hundreds, if not thousands, in attacks inside China in a decades-long insurgency that initially targeted police and other symbols of Chinese authority but in recent years also included civilians. Extremists with knives killed 33 people at a train station in 2014. Abroad, they bombed the Chinese embassy in Kyrgyzstan in September last year; in 2014, they killed 25 people in an attack on a Thai shrine popular with Chinese tourists.

China is just like the West, its officials say: the country is a victim of terror, and Uighur men are pulled by global jihadi ideology rather than driven by grievances at home. Muslims in the Uighur homeland of Xinjiang, as one Chinese official declared in August, "are the happiest in the world."

But rare and extensive Associated Press interviews with nine Uighurs who had left China to train and fight in Syria showed that Uighurs don't neatly fit the profile of foreign fighters answering the call of jihad.

There was a police trainer who journeyed thousands of miles with his wife and children to Syria, a war zone. A farmer who balked at fundamentalist Islam even though he charged into battle alongside al-Qaida. A shopkeeper who prayed five times a day and then at night huddled with others in a ruined Syrian neighborhood to study Zionist history.

And there was Ali, a short, soft-spoken 30-year-old with a primary school education who knew little of the world beyond his 35-acre farm when he left China, a home that had become unlivable.

Sitting cross-legged one recent evening in an empty apartment overlooking a kickboxing gym in Istanbul, he recalled the vow he made the night Chinese police beat him for participating in a riot he never joined.

"I'll get revenge," he said.

___

SELF-FULFILLING PROPHECY

Ali's parents eventually got him out of detention — but it cost them 10,000 yuan ($1,500) in bribes to local officials, no small amount for the family of farmers.

Despite his release, Ali was not free.

It was late 2009, and Xinjiang was in lockdown. Four months earlier, hundreds of Uighurs had rioted in Urumqi, the capital of Xinjiang, and attacked the Han, China's dominant ethnic group. An estimated 200 people died in the unrest that night, the bloodiest ethnic violence the country had seen in decades and an event that would change Ali's life and that of 10 million Uighurs in Xinjiang.

The government, caught off-guard by the unrest, rolled out an expansive security crackdown and surveillance programs in the region that have accelerated in the last year . Thousands of Uighurs, including moderate Uighur intellectuals, are believed to have been arrested or detained, some of them without trial.

Ali was constantly stopped and questioned wherever he went. He couldn't check into a hotel, buy a train ticket or get a passport.

"I had nowhere to go," he said. "Except out."

As the repression mounted, what began as a trickle of Uighurs fleeing China grew into a mass exodus. In 2013, more than 10,000 left across southern China's porous borders, according to Uighur exiles. Nearly all the Uighurs who spoke to the AP after returning to Turkey from Syria recounted being persecuted by Chinese authorities as a motive for taking up arms.

"The Chinese government had been accusing Uighurs of militancy for a long time when there hasn't been much of a threat," said Sean R. Roberts, an expert on Uighur issues at George Washington University. "That changed after the 2009 crackdown. It's become a self-fulfilling prophecy."

___

ESCAPE AND ROAD TO SYRIA

Desperate to leave China, Ali paid more than 100,000 yuan ($15,000) to human smugglers and made his way overland through Laos, Cambodia, Thailand and Malaysia, where he received a Turkish travel document.

In Turkey, Ali drifted in Istanbul, working construction and electrical jobs for $300 a month. Within two months, his brother said he had met people who could take them to Syria, where they could learn weapons training and return to China to "liberate" their friends and family.

"We'll avenge our relatives being tortured in Chinese jail," he said.

Ali agreed, thinking they would go for a few weeks. They ended up spending two-and-a-half years in Syria.

The story of how Ali ended up in a distant war zone echoed the experiences of other Uighurs the AP spoke to in Turkey, who said they joined religious militant groups at first because of grievances against Beijing or support for the idea of a Uighur nation. Most knew little about political Islam that fueled jihadis in other countries, and none said they met with recruiters inside China.

But that changed as soon as they left China's borders. As Uighur refugees traveled along an underground railroad in Southeast Asia, they said, they were greeted by a network of Uighur militants who offered food and shelter — and their extremist ideology. And when the refugees touched down in Turkey, they were again wooed by recruiters who openly roamed the streets of Istanbul in gritty immigrant neighborhoods like Zeytinburnu and Sefakoy, looking for fresh fighters to shuttle to Syria.

Uighur activists and Syrian and Chinese officials estimate that at least 5,000 Uighurs have gone to Syria to fight — though many have since left. Among those, several hundred have joined the Islamic State, according to former fighters and Syrian officials.

As Uighurs streamed out of China, militant leaders have seized upon China's treatment of Muslims as a recruiting tactic. The Islamic State, for instance, regularly publishes Uighur-language editions of its radio bulletins and magazines, while the Turkistan Islamic Party has been releasing videos on a near-weekly basis, said Rita Katz, director of the SITE Intelligence monitoring group.

"How can those who are imprisoned due to their faith be freed? How can they be saved from this humiliation?" a masked Uighur fighter says in a Turkestan Islamic Party video released last year. "Words from our mouths won't help, but jihad for Allah will."

___

A FARAWAY WAR

From Istanbul, several of the former fighters described taking buses or being driven to the border region of Hatay, where they would cross on foot at night through lightly guarded hills. After a three-hour hike into Syria, cars waited in a forest clearing to whisk them to separate camps dotting the country's north. One fighter said he simply drove in, unobstructed, on the highway from the Turkish city of Gaziantep.

When the Uighurs arrived in Jisr al-Shughour, a strategic town on the edge of Assad's stronghold of Latakia region, men with families, like Ali, moved into a ruined neighborhood of single-story brick homes where 150 families stayed. Single men lived together in larger apartment buildings.

The men undertook three-month training sessions in the use of Soviet AKM rifles, shoulder-mounted rocket-propelled grenade launchers, physical conditioning and mapping.

At the beginning of the course, the trainers showed off their prized cache of captured American M-16s and German G3 rifles, but each fighter received a battered AKM and cheap Chinese ammunition. Boys as young as 12 and 13 — mostly orphans — were taken to a separate camp for religious classes and physical training.

Two fighters said they received boxes of food from IHH, a Turkish Islamic charity group, that included rice, flour, meat and even fish imported from Thailand. One of the fighters said the food supplies were labeled with the foreign fighting group they were being shipped to — for example, "Turkistanis (Uighurs) or Uzbeks."

IHH spokesman Mustafa Ozbek said the group distributes aid in refugee camps near the Syrian border to civilians, but not armed groups.

"All of our aid is conducted officially, documented and reported," Ozbek said.

The Uighurs in Syria have a reputation for administering their territory with a light touch, said Aymenn Jawad al-Tamimi, a British researcher at the Middle East Forum who has extensively interviewed jihadis in Syria, including Uighur fighters. They don't enforce an Islamic court system or replace local councils — unlike their close allies, the al-Qaida-linked Hay'at Tahrir al-Sham, Arabic for Levant Liberation Committee.

Instead, an older Uighur would convene young fighters in the evenings to discuss history and politics. They looked to an improbable model for building an independent homeland: Israel and the Zionist movement.

"We studied how the Jews built their country," Ali said. "Some of them fought, some of them provided money. We don't have a strong background of that."

Few Uighurs spoke Arabic and most didn't mingle with locals, but at one point some residents joked that Uighurs should rename the city Shughuristan, a play on "East Turkistan," the Uighur exiles' preferred name for their homeland. The Uighurs were unconvinced.

"This is not our homeland," Ali and his comrades told the Arabs. "We want our homeland, we don't need yours."

___

FEARLESS 'PAWNS'

Like Ali, Rozi Mehmet wanted to do something to help his people fight Chinese oppression. His grandfather, a wealthy Uighur farmer, had been executed in the tumult of China's Cultural Revolution in the 1960s.

Three years ago, Mehmet left the ancient oasis town of Hotan and hiked into Syria to join a class of 52 Turkistan Islamic Party trainees.

Within six months, he would be on the front lines with a rocket-propelled grenade launcher strapped to his skinny back, sprinting toward government positions near Jisr al-Shughour.

Jihadi clerics have exhorted Uighurs to take up holy war and reap the rewards of martyrdom. But if he would take a bullet, Mehmet thought as he rushed into battle, he wasn't dying for Islam — or the virgins that the preachers promised. His homeland was the only thing on his mind.

"I didn't feel fear," he told the AP. "If I felt fear, how could I be able to build my country?"

As fighting escalated in 2015 and 2016, hundreds of Uighurs died in its campaigns alongside al-Qaida's Nusra Front, according to two former fighters who fought in northern Syria.

Radical groups have aggressively recruited Uighurs. Al-Qaida's leader promised in a video that Islamic militants would repay the Uighurs by striking at "atheist Chinese occupiers" after the Syrian war. The Islamic State has echoed similar pledges and the group in March released a Uighur-language propaganda video vowing to one day shed Chinese blood if Uighurs would join the Syrian struggle.

As the chaotic opposition splintered and reorganized, groups vied for the Uighurs' support and lauded them for their suicide attacks that often kept the Syrian army off-balance, Mehmet boasted.

An older fighter, also from Hotan, chided the young man, saying he was more cynical about why the Arab jihadis lavished them with praise.

"They praise us, which means they want us to follow them and fight for them," said Rozi Tohti, 40, who fought near the city of Idlib. They "are trying to lure us to become their pawns."

___

DISSENT IN SYRIA; THREAT TO CHINA

But several Uighur fighters insisted that, in their minds, there was a distinct line between themselves and the Islamic militants they fought beside. Some Uighurs complained about being stuck in Syria instead of attacking China, as they had been promised.

"We fight for them and help them control the country, and then Uighurs are left with nothing," Mehmet said.

After joining the TIP in mid-2015, Uighur fighter Abdulrehim visited a graveyard for fallen militants and wondered why there were no Uighur national banners. At one point, he openly challenged a TIP senior leader, Ibrahim Mansour, about what they were doing in Syria, he recalled.

"We haven't fired a bullet against our enemy, China," he told a group of gathered Uighur fighters. "We always fight alongside international terrorists. What's going on here?"

Many Uighur militants have grown tired of the war and are looking to leave particularly as Assad's forces gain the upper hand, says Seyit Tumturk, a Uighur activist in Turkey who often speaks to fighters in Syria.

He said it was impossible for Uighurs militants to liberate Xinjiang, currently blanketed with paramilitary forces and riot police. But he said Chinese President Xi Jinping's ambitious project to develop railway lines, ports, and other infrastructure linking various regions to China makes Beijing vulnerable to militant attacks abroad.

The Islamic State took credit in June for kidnapping and killing two Chinese teachers in Pakistan's Baluchistan province, which is a cornerstone of Beijing's so-called Belt and Road infrastructure project. In Kyrgyzstan, state security say a suicide bombing of the Chinese embassy in Bishkek was ordered by Uighur terrorist groups active in Syria and financed by al-Qaida's Nusra Front.

Chinese officials and Western analysts alike say that the Uighurs' experience in the Syrian jihadi melting pot will likely exacerbate violence against "soft" targets outside China. China's foreign ministry called the Turkistan Islamic Party a security threat for the Middle East.

"We hope our brothers, including Syria and Turkey, will work with us, strengthen cooperation and cut off the terrorists' cross-border movements and safeguard regional stability," the ministry said in a faxed statement in response to questions from the AP.

The ministry did not address questions about the causes of radicalization but said that China's government has invested heavily in Xinjiang's economic development, protected its minorities' rights and treated them just as every other ethnic group.

"Of course, when there are those who try to create tension in Xinjiang, the Chinese government's commitment to striking against violent terror and ethnic splittism is unquestioned," it said.

___

RETURN TO TURKEY AND AN UNCERTAIN FUTURE

By June of this year, Ali had tired of Syria and wanted to get out. For him, the war consisted of spending months at a time manning checkpoints and patrolling borders.

But like many other Uighurs who sought to return to Turkey, he struggled to find a way back. Ali walked for a week to get around a wall built by the Turkish government on the border. He's now back in Istanbul and selling milk.

Although some of the Uighur returnees said they would attack China if the opportunity arose, others balked at the idea.

Uighur community workers are concerned that many of those cast back into Turkish society would struggle to integrate and be easily pulled back into radical groups. Many of the men make $200 to $300 a month, barely enough to cover rent in Istanbul, and spoke poor Turkish. Many faced daily discrimination.

Activists also worry about TIP recruitment continuing unchecked in Turkey, where it appears to have a degree of official support.

This year, Turkish authorities detained TIP members including a former top commander, ostensibly for his own safety, said a diplomat in Beijing and a Uighur activist who was allowed by Turkish officials to speak with him. But Turkey refused to allow Chinese intelligence to interrogate the former commander, deeply frustrating Beijing, the diplomat said.

Uighur leaders say Turkish police also have released several well-known Uighur jihadi recruiters even after the community offered tips that led to their arrest.

"There are suspicions that these recruiters have links with some individuals or agencies within the government," said Omer Kanat, director of the Uyghur Human Rights Project in Washington. "They're turning a blind eye."

Rozi Tohti, the middle-aged fighter from Hotan, sat in a meadow facing the ruined walls of old Constantinople and ruminated on the choices facing his compatriots in Turkey: give their lives to a radical Islamic movement that they did not believe in or struggle to settle into a Turkish society where they did not fit in.

One thing was clear. Returning to their homeland was out of the question.

"Who wants to live in a war zone?" Tohti said. "We once had paradise in our country. But it was being erased by the Chinese, so instead we looked for paradise in Syria."