ISTANBUL (Reuters) - Turkey will “do what is necessary” to prevent U.S.-allied Syrian Kurdish rebels from declaring autonomy in the town of Tel Abyad near the Turkish border, including conducting further military operations, President Tayyip Erdogan said on Wednesday.

Turkish President Tayyip Erdogan gives a speech during an inauguration ceremony of a water pipeline project linking Turkey to northern Cyprus, in Myrtoy October 17, 2015. REUTERS/Yiannis Kourtoglou

NATO member Turkey is part of the U.S.-led coalition fighting Islamic State militants in Syria, but it sees advances by autonomy-seeking Kurds, led by the Democratic Union Party (PYD), as a threat to its own national security, fearing they could stoke separatism among Turkish Kurds.

Turkish jets recently hit the Syrian Kurds’ armed People’s Protection Units (YPG) targets twice after they defied Ankara and crossed west of the Euphrates River.

“This was a warning. ‘Pull yourself together. If you try to do this elsewhere - Turkey doesn’t need permission from anyone - we will do what is necessary,’” Erdogan said, signaling he could defy Washington’s demand that Ankara avoid hitting Syrian Kurds and focus its military might on Islamic State targets.

Erdogan, in remarks broadcast live on the Kanal 24 television station, also accused the PYD of carrying out “ethnic cleansing” in the area and said Western support for the Syrian Kurdish militias amounted to aiding terrorism.

Backed by U.S.-led air strikes, YPD fighters captured Tel Abyad in June from Islamic State, and this month a local leadership council declared the town part of the system of autonomous self-governing “cantons” run by the Kurds.

“The PYD is committing ethnic cleansing here (of) Arabs and Turkmen,” Erdogan said. “If the Kurds withdraw and don’t form a canton, there’s no problem. But if the mindset continues, then what is necessary will be done or we face serious problems.

“We are determined to (combat) anything that threatens us along the Syrian border, inside or out.”

Turkey does not want to see an autonomous Kurdish entity resembling Iraqi Kurdistan emerging on its southern flank, said Erdogan, speaking days before a Turkish parliamentary election that has aggravated political and security tensions.

Western allies are now arming the Kurds, he added.

“They don’t even accept the PYD as a terrorist organization. What kind of nonsense is this?” he said. “The West still has the mentality of ‘My terrorist is good, yours is bad.’”

Within Turkey, the armed forces have resumed their 30-year fight with militants of the Kurdistan Workers Party (PKK), which wants autonomy for the Turkish Kurds and also has close links with their ethnic brethren across the border in Syria.

Erdogan said 1,400 PKK militants were fighting alongside the YPG in Syria.

The United States and Europe, like Turkey, classify the PKK as a terrorist organization but regard the Syrian and Iraqi Kurdish groupings as valuable allies in the fight against Islamic State and other jihadis.