Turkey will not let Kurdish militia fighters backed by the United States establish a foothold on its border in northern Syria and will not stop shelling if its security is threatened, President Tayyip Erdogan said on Wednesday.

The Kurdish YPG militia, regarded by Ankara as a hostile insurgent group, has taken advantage in recent weeks of a major Syrian army offensive around the city of Aleppo, backed by Russian air strikes, to seize ground from Syrian rebels near the Turkish border.

Their gains have infuriated Turkey, which has shelled YPG positions in Syria in response to what it says is fire coming across the border. They have also complicated wider efforts to end the Syrian conflict, deepening divisions between NATO member Turkey and the United States, which views the YPG as a useful ally in the fight against Islamic State.

"Today our rules of engagement may be just about responding to an armed attack against our country, but tomorrow if necessary those rules can be expanded to cover every threat," Erdogan said in a speech broadcast live on television.

"Nobody should doubt that. We will not allow the formation of a new 'Qandil' on our southern border," he said, referring to the Qandil mountains of northern Iraq, where the outlawed Kurdistan Workers Party (PKK) has established bases during a three-decade insurgency against the Turkish state.

Turkey argues that the YPG is an extension of the PKK, deemed a terrorist group by the United States and European Union. It accuses the YPG of pursuing "demographic change" in northern Syria by forcibly displacing Turkmen and Arab communities, as well as Kurds who do not share its ideology.

Ankara ultimately fears the creation of an independent Kurdish state occupying contiguous territories currently belonging to Iraq, Syria and Turkey.

Turkey Syria

Turkish artillery fire from the border near Kilis toward northern Syria, in Kilis, Turkey, on Monday. Turkey insisted it would not allow Kurdish-led forces to seize key areas along the border. (Halit Onur Sandal/Associated Press)

Erdogan said he could not understand why Washington refused to call the YPG and its political wing, the PYD, a terrorist organisation. Ignoring their links to the PKK was, he said, a hostile attitude to Turkey and reiterated comments of recent days asking the United States to choose its allies: "We want to know: are your friends the YPG, PYD, or us," he said.

Washington has told the YPG to avoid doing anything to increase tensions with Turkey, saying they undermine the struggle against Islamic State, but has also urged Turkey to cease artillery fire across its border, U.S. State Department spokesman Mark Toner said on Tuesday.

Renewed calls for 'safe zone' 

Deputy Prime Minister Yalcin Akdogan said Turkey wants a secure strip of territory 10 kilometres deep on the Syrian side of its border, including the town of Azaz, to prevent attempts to "change the demographic structure" of the area.

Azaz is the last rebel stronghold before the border with Turkey north of the Syrian city of Aleppo, part of what was, before the Syrian government offensive, a supply route from Turkey to the rebels fighting President Bashar al-Assad.

It has come under heavy assault in recent days, but Turkey has said it will not let the town fall into YPG hands.

"There is a game being played with the aim of changing the demographic structure. Turkey should not be part of this game," Akdogan said in an interview on the AHaber television station.

"What we want is to create a secure strip, including Azaz, 10 kilometres deep inside Syria and this zone should be free from clashes," he said.

Turkey, home to more than 2.6 million Syrian refugees, has long pushed for the creation of a safe zone in Syria to protect displaced civilians without bringing them into Turkey.

The proposal has so far gained little traction with Washington or NATO allies who fear it would require an internationally patrolled no-fly zone which could put them in direct confrontation with Assad and his allies.

But Erdogan said some countries were warming to the idea.

German Chancellor Angela Merkel, under pressure at home over her open-door policy for refugees, said on Wednesday that it would be good for the people in Aleppo and the area around it to create "a kind of no fly zone" up to the Turkish border, reiterating comments she made on Monday. Akdogan said another 600,000 people could flee to the Turkish border if Aleppo falls to the Syrian army.