Turkish forces and members of the Free Syrian Army are seen on the outskirts of al-Bab in Syria on Feb. 4, 2017. (Khalil Ashawi/Reuters)

A Russian airstrike in northern Syria killed three Turkish soldiers and wounded 11 others Thursday, in a friendly fire incident that could test the shaky coordination between the two countries in the fight against the Islamic State.

Russia and Turkey both described the morning attack as accidental, saying a bomb hit a building used by Turkish troops near the northern Syrian town of al-Bab. Turkish forces­ are launching an offensive to retake the town from the Islamic State.

The two countries quickly took steps to limit fallout from the incident. Russian President Vladimir Putin expressed condolences to Turkish President Recep Tayyip Erdogan in a telephone call and blamed the strike on poor coordination, according to a Kremlin spokesman. The Russian Defense Ministry said the strike was meant to hit Islamic State targets.

The deaths added to a heavy toll suffered by Turkish troops embroiled in an increasingly complicated and bloody fight to help Syrian rebels capture al-Bab from the Islamic State. Five died Wednesday, and the latest deaths brought the number of Turkish soldiers killed in the two-month battle to more than 60.

In a short statement, the Turkish armed forces­ said Russian officials had expressed their “sadness and condolences.” It added that “investigation and studies related to the event will be carried out by both sides.”

Moscow and Ankara appeared close to the brink of war in late 2015 after Turkish jets shot down a Russian warplane over Turkey’s border with Syria. But Putin restored relations with Erdogan after a coup attempt nearly unseated the Turkish leader in July. 

The two countries have increased their coordination in Syria, where Turkish-backed rebels have sought to overthrow President Bashar al-Assad, a Moscow ally. Last month, Russia, Turkey and Iran hosted talks in Kazakhstan to manage a cease-fire between rebel factions and the Syrian government, and Russian and Turkish officials announced that they would begin coordinating strikes against the Islamic State.

The two countries’ relations have warmed despite dramatic incidents, including the assassination of Russia’s ambassador to Turkey in December by a gunman who yelled, “God is great!” and “Don’t forget Aleppo! Don’t forget Syria!”

In recent days, rebel and Turkish reinforcements have been converging from the north on the outskirts of al-Bab for what rebel commanders said is expected to be a major push to eject the militants.

Meanwhile, Syrian government forces­ have also been advancing on the town from the south, setting up a race for control of al-Bab between Turkish-backed forces­ and those loyal to Assad.

Russia has been providing air support to both sides as they advance. It was unclear whether the errant strike Thursday was conducted in support of Syrian or Turkish operations there.

The attack also coincided with reports of the first direct clashes­ between Syrian forces­ and Turkish-backed rebels on the outskirts of al-Bab, threatening to turn the battle into a three-front, international war. Photographs posted on social media by rebel groups showed rebels driving an armored vehicle that was said to have been commandeered from government ­forces.

Erdogan is hoping to persuade U.S. military commanders to partner with the Turkish-backed force fighting in Syria — rather than arm Syrian Kurdish fighters linked to the Kurdistan Workers’ Party, or PKK, which is designated a terrorist group by Turkey and the United States. The ground force would be used in a final assault on the Islamic State’s self-proclaimed capital in the northern Syrian city of Raqqa.  

President Trump’s advisers have been skeptical about a plan to arm the Kurds but have not ruled it out. 

Sly reported from Beirut. Kareem Fahim in Istanbul contributed to this report.