ANKARA/ISTANBUL Turkish Prime Minister Ahmet Davutoglu blamed a Syrian Kurdish militia fighter working with Kurdish militants inside Turkey for a suicide car bombing that killed 28 people in the capital Ankara, and he vowed retaliation in both Syria and Iraq.

A car laden with explosives detonated next to military buses as they waited at traffic lights near Turkey's armed forces' headquarters, parliament and government buildings in the administrative heart of Ankara late on Wednesday.

Davutoglu said the attack was clear evidence that the YPG, a Syrian Kurdish militia that has been supported by the United States in the fight against Islamic State in northern Syria, was a terrorist organisation and that Turkey, a NATO member, expected cooperation from its allies in combating the group.

Within hours, Turkish warplanes bombed bases in northern Iraq of the Kurdistan Workers Party (PKK), which has waged a three-decade insurgency against the Turkish state and which Davutoglu accused of collaborating in the car bombing.

Turkey's armed forces also shelled YPG positions in northern Syria on Thursday, a security source said. Davutoglu said the artillery fire would continue and promised that those responsible for the Ankara attack would "pay the price".

"Yesterday's attack was directly targeting Turkey and the perpetrator is the YPG and the divisive terrorist organisation PKK. All necessary measures will be taken against them," Davutoglu said in a televised speech.

President Tayyip Erdogan also said initial findings suggested the Syrian Kurdish militia and the PKK were behind the bombing and said that 14 people had been detained.

The political arm of the YPG, denied involvement in the bombing, while a senior member of the PKK said he did not know who was responsible.

The attack was the latest in a series of bombings in the past year mostly blamed on Islamic State militants.

Turkey is getting dragged ever deeper into the war in neighbouring Syria and is trying to contain some of the fiercest violence in decades in its predominantly Kurdish southeast.

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

That has alarmed Turkey, which fears the advances will stoke Kurdish separatist ambitions at home. It has been bombarding YPG positions in an effort to stop them taking the town of Azaz, the last stronghold of Turkish-backed Syrian rebels north of Aleppo before the Turkish frontier.

Hundreds of Syrian rebels with weapons and vehicles have re-entered Syria from Turkey over the last week to reinforce insurgents fending off the Kurdish-led assault on Azaz, rebel sources said on Thursday.

TENSIONS WITH WASHINGTON

The co-leader of the YPG's political wing denied that the affiliated YPG perpetrated the Ankara bombing and said Turkey was using the attack to justify an escalation in fighting in northern Syria.

"We are completely refuting that. ...Davutoglu is preparing for something else because they are shelling us as you know for the past week," Saleh Muslim told Reuters by telephone.

Washington's support of the YPG - it views the group as a useful ally in the fight against Islamic State - has strained relations with Turkey. Both Erdogan and Davutoglu have called on the United States to cut ties with the insurgents.

State Department spokesman John Kirby said Washington was not in a position to either confirm or deny Turkey's charge the YPG was behind the attack. He also called on Turkey to stop shelling the YPG.

Turkey has said its shelling of YPG positions is a response, within its rules of engagement, to hostile fire coming across the border into Turkey, something Saleh Muslim also denied.

"I can assure you not even one bullet is fired by the YPG into Turkey ... They don't consider Turkey an enemy," he said.

The co-leader of the PKK umbrella group, Cemil Bayik, was quoted by the Firat news agency as saying he did not know who was responsible for the Ankara bombing. But the attack, he said, could be an answer to "massacres in Kurdistan", referring to the Kurdish region spanning parts of Turkey, Syria, Iraq and Iran.

Turkey has been battling PKK militants in its own southeast, where a 2-1/2 year ceasefire collapsed last July and pitched the region into its worst bloodshed since the 1990s. Six soldiers were killed and one wounded on Thursday when a remote-controlled handmade bomb hit their vehicle, the military said.

WARNING TO RUSSIA

Davutoglu named the suicide bomber as Salih Necar, born in 1992 and from the Hasakah region of northern Syria, and said he was a member of the YPG.

A senior security official said the alleged bomber had entered Turkey from Syria in July 2014, although he may have crossed the border illegally multiple times before that, and said he had had contact with the PKK and Syrian intelligence.

Davutoglu also accused the Syrian government of a hand in the Ankara bombing and warned Russia, whose air strikes in northern Syria have helped the YPG to advance, against using the Kurdish militant group against Turkey.

"I'd like to warn Russia, which is giving air support to the YPG in its advance on Azaz, not to use this terrorist group against the innocent people of Syria and Turkey," he said.

"Russia condemned yesterday's attack, but it is not enough. All those who intend to use terrorist organisations as proxies should know that this game of terror will turn around like a boomerang and hit them first."

Russian President Vladimir Putin's spokesman, Dmitry Peskov, told a teleconference with reporters that the Kremlin condemned the bombing "in the strongest possible terms".