Beijing: Turkey will not allow its soil to be used for activities that damage China’s security, the two countries’ foreign ministers agreed on Wednesday, following recent disputes over China’s Muslim Uighur ethnic minority that had soured ties.

Hundreds, possibly thousands, of Uighurs keen to escape unrest in China’s western Xinjiang region have travelled clandestinely via Southeast Asia to Turkey, where many see themselves as sharing religious and cultural ties.

Beijing says some Uighurs then end up fighting with militants in Iraq and Syria. But Ankara vowed last year to keep its doors open to Uighur migrants fleeing what rights activists have called religious persecution in China.

Beijing denies accusations that it restricts the Uighurs’ religious freedoms.

It blames Islamist militants, including those it says come from a group called the East Turkestan Islamic Movement (ETIM), for a rise in violence in Xinjiang in recent years in which hundreds have died.

The two countries will “jointly fight terrorist groups, including ETIM, oppose extremism and constrain illegal immigration”, a statement on the ministry’s website cited Chinese Foreign Minister Wang Yi as saying.

Turkish Foreign Minister Mevlut Cavusoglu agreed to improve antiterrorism cooperation when the two met ahead of an Asia security forum in Beijing this week.

“Turkey will take all necessary steps to strengthen bilateral antiterrorism cooperation, combat illegal immigration, fight ETIM, continue to emphasise China’s security concerns and not allow anyone in Turkey to engage in activities that harm China’s security,” the Chinese statement cited Cavusoglu as saying.

China is home to about 20 million Muslims spread across its vast territory, only a portion of whom are Uighurs.

Officials in Xinjiang have stepped up regulations banning overt signs of religious observance, like veils or beards.

Rights groups say the unrest there is more a reaction to repressive government policies, and experts have questioned whether ETIM exists as a cohesive militant group.

Turkey angered China by expressing concern about reports of restrictions on Uighurs worshipping and fasting during the holy month of Ramadan last year, and Turkish protesters have marched to China’s embassy and consulate in Turkey over Beijing’s treatment of Uighurs.

The two countries have also jousted over Thailand’s deportation of Uighur migrants back to China.