ISTANBUL (Reuters) - Days after a reshuffle of Turkey’s top military commanders, President Tayyip Erdogan has revived warnings of military action against Kurdish fighters in Syria that could set back the U.S.-led battle against Islamic State.

Turkish President Tayyip Erdogan makes a speech during the re-opening of the Ottoman-era Yildiz Hamidiye mosque in Istanbul, Turkey, August 4, 2017. Picture taken August 4, 2017. REUTERS/Murad Sezer

Kurdish militia are spearheading an assault against the hardline militants in their Syrian stronghold Raqqa, from where Islamic State has planned attacks around the world for the past three years.

But U.S. backing for the Kurdish YPG fighters in Syria has infuriated Turkey, which views their growing battlefield strength as a security threat due to a decades-old insurgency by the Kurdish PKK within in its borders.

There have been regular exchanges of rocket and artillery fire in recent weeks between Turkish forces and YPG fighters who control part of Syria’s northwestern border.

Turkey, which has the second largest army in NATO after the United States, reinforced that section of the border at the weekend with artillery and tanks and Erdogan said Turkey was ready to take action.

“We will not leave the separatist organization in peace in both Iraq and Syria,” Erdogan said in a speech on Saturday in the eastern town of Malatya, referring to the YPG in Syria and PKK bases in Iraq. “We know that if we do not drain the swamp, we cannot get rid of flies.”

The YPG denies Turkish allegations of links with Kurdish militants inside Turkey, saying it is only interested in self-rule in Syria and warning that any Turkish assault will draw its fighters away from the battle against Islamic State which they are waging in an alliance with local Arab forces.

Erdogan’s comments follow the appointment of three new leaders of Turkey’s army, air force and navy last week - moves which analysts and officials said were at least partly aimed at preparing for any campaign against the YPG militia.

Turkish forces swept into north Syria last year to seize territory from Islamic State, while also cutting off Kurdish-controlled northeast Syria from the Kurdish pocket of Afrin further west. They thereby prevented Kurdish control over almost the whole sweep of the border - Ankara’s worst-case scenario.

Recent clashes have centered around the Arab towns of Tal Rifaat and Minnigh, near Afrin, which are held by the Kurdish YPG and allied fighters.

Erdogan said Turkey’s military incursion last year dealt a blow to “terrorist projects” in the region and promised further action. “We will make new and important moves soon,” he said.

“MORE ACTIVE” FIGHT

His comments follow weeks of warnings from Turkey of possible military action against the YPG.

Washington’s concern to prevent any confrontation which deflects the Kurdish forces attacking Raqqa may help stay Ankara’s hand, but a Turkish government source said last week’s changes in military leadership have prepared the ground.

“With this new structure, some steps will be taken to be more active in the struggle against terror,” the source said. “A structure that acts according to the realities of the region will be formed”.

The battle for Raqqa has been underway since June, and a senior U.S. official said on Friday that 2,000 Islamic State fighters are believed to be still defending positions and “fighting for every last block” in the city.

Even after the recapture of Raqqa, U.S. Defense Secretary Jim Mattis has left open the possibility of longer-term American assistance to the YPG.

Slideshow ( 4 images )

The influence of Turkey’s once-dominant military has decreased dramatically since Erdogan came to power nearly 15 years ago. A purge in senior ranks since last year’s failed military coup has stripped it of 40 percent of top officers.

Last Wednesday’s appointments were issued by the Supreme Military Council, a body which despite its name is now dominated by politicians loyal to Erdogan.

“Of course the political will is behind these decisions, Erdogan’s preferences are behind them,” the source said. “But the restructuring of the Turkish Armed Forces and the demand for a more active fight against the PKK and Islamic State also has a role”.

Vacancies in senior military ranks resulting from the year-long purge would not be filled immediately, he said, but would be addressed over time.

While all three forces - air, land and sea - are under new command, focus has centered on the new army chief Yasar Guler. As head of Turkey’s gendarmerie, he was seen to take a tough line against the PKK and the movement of U.S.-based cleric Fethullah Gulen blamed by the government for the July 2016 coup attempt.

Ankara considers the YPG an extension of the PKK, which is designated a terrorist organization by Turkey, the United States and European Union.

Can Kasapoglu, a defense analyst at the Istanbul-based Center for Economics and Foreign Policy Studies (EDAM), said the YPG “remains at the epicenter of Turkey’s threat perception”.

Guler was well-placed to address Turkey’s “transnational counter-terrorism priorities” and lead the campaign against Kurdish forces because of his past roles as chief of military intelligence, head of gendarmerie and postings to NATO.

“There is an undeniable likelihood that Turkey’s new top military chain of command might have to lead a major campaign against the YPG,” Kasapoglu said.

Guler is now favorite to take over from the overall head of the Turkish armed forces, General Hulusi Akar, who is due to step down in two years.

“Guler gets on well with members of Erdogan’s AK Party and is known for his hardline performance against the PKK...and the Gulen movement,” said Metin Gurcan an independent security analyst and retired Turkish military officer who now writes a column for Al-Monitor news website.

For the president, who faces a re-election campaign in 2019, a smooth succession from Akar to Guler would avoid any military upheaval which could send his plans off-course, Gurcan said.

“Until 2023, Erdogan should have smooth sailing without disruption from the Turkish armed forces.”