Updated

Nearly two months into the assault, Turkey has become bogged down in an unexpectedly bloody fight to retake the Islamic State group's last stronghold in northern Syria. It has been forced to pour in troops, take the lead in the battle from its Syrian allies and reach out to Russia for aerial support.

The fight for al-Bab underscores the precarious path Ankara is treading with its foray in to Syria, aimed against both IS militants and Syrian Kurdish fighters. The assault on the town had already driven a wedge between Turkey and the United States, and now the realignment toward Moscow — which supports the government in Syria's civil war — further tests Ankara's alliance both with Washington and with the Syrian opposition.

The battle itself has proven grueling.

Nearly 50 Turkish soldiers have been killed in its Syria operation, most of them since the al-Bab assault began in mid-November — including 14 killed in a single day. The militants have dug in, surrounding the town with trenches, lining streets with land mines and carrying out painful ambushes and car bombings against the besieging forces. Each time Turkish-backed Syrian opposition fighters have thrust into the city, they've been driven out. More than 200 civilians are believed to have been killed since the attack began Nov. 13. Mud and cold rain have only made it more of a slog.

"The battle for al-Bab has been mostly about killing civilians and destroying the city, whether by Daesh or the Turks," said Mustafa Sultan, a resident of al-Bab and a media activist who has been covering the fight. He used the Arabic acronym for IS.

"The town is almost half destroyed. Daesh takes cover in hospitals, schools and these end up getting targeted," he said. The Turkish military says it takes great care not to harm civilians, halting operations that could endanger non-combatants.

Capturing al-Bab is essential to Ankara's goals in Syria.

Turkey, which for years supported the Syrian opposition drive to oust President Bashar Assad, has recalibrated its priorities toward fighting Islamic State militants who turned their terror against the Turkish state and thwarting Kurdish aspirations for autonomous rule along Syria's border with Turkey.

If al-Bab is retaken, it would break the IS presence near the border and plant a Turkish-backed presence between Kurdish-held territory to the east and west, preventing them from linking.

For the U.S., the al-Bab assault risks causing direct confrontation between Turkish troops and Syrian Kurdish forces, which are leading a U.S.-backed offensive toward the de facto IS capital, Raqqa. Washington supports and relies on the Kurds in the fight against IS the past two years.

Last month, Ankara protested to Washington that its NATO ally was providing no help in al-Bab. A day later, Turkey said Russia carried out three airstrikes in the al-Bab area.

In the short term, Turkey is likely to sending a message to the United States before President-elect Donald Trump takes office that it has other options if Washington keeps backing the Syrian Kurds, considered by Ankara as terrorists linked to a Kurdish faction that has carried out bombings in Turkey.

In the long term, President Recep Tayyip Erdogan may be exploring his options with Russia, which currently holds the key to Syria militarily and diplomatically. Russia helped Assad's forces crush the opposition enclave in the northern city of Aleppo in December. Then Moscow and Ankara joined to broker a ceasefire, which is supposed to lead to negotiations later this month.

Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff, said Tuesday the U.S. has seen no indication of Russian-Turkish coordination, only independent Russian airstrikes in al-Bab.

"I don't think the United States is very worried about Erdogan flipping from NATO to Moscow, but they are worried about Turkey's general drift into instability and rash decisions. Erdogan bungling his foreign policy to the point where he must turn to Putin for help is certainly part of that broader concern," said Aron Lund, a fellow at the New York-based Century Foundation.

Following Turkey's protest, U.S. officials said discussions with Ankara continue over al-Bab, an important effort against IS. Turkey said on Dec. 30 that the U.S.-led coalition carried out an airstrike in the al-Bab region.

The offensive has also revealed how unprepared Turkish-allied Syrian rebels are for a protracted fight against IS.

Ankara increased its initial deployment of 600 soldiers — which included special forces and mechanized battalions — to at least 4,000 today, according to Metin Gurcan, a former Turkish military adviser who served in Afghanistan, Kazakhstan and Iraq and is now an independent security analyst. Turkish troops now outnumber the Syrian opposition fighters who were supposed to be "the primary ground force," Gurcan wrote in Al-Monitor.

He said some Syrian fighters have withdrawn, "and because of their lack of discipline in the field, Turkish commandos are now engaged in front-line fighting against IS."

Unlike the IS-held town of Jarablus, which Turkey's allies entered almost without a fight in August, the militant group prepared to defend al-Bab. IS fighters have taken positions on hilltops, used drones and have repeatedly shown a capability in waging pitched battles.

After Turkish troops and Syrian fighters secured a strategic hilltop on the town's edge in late December, IS launched a surprise counteroffensive, killing 14 Turkish soldiers and over two dozen Syrians.

One Syrian opposition commander said there were three different battles around the hill. "We had to pull out more than once because they encircled us and we had many martyrs," he said, speaking on condition of anonymity to discuss battlefield details.

Another battle on the eastern side of al-Bab lasted 15 hours, starting from hilltops and ending in a valley at close range with dozens killed and many damaged armored vehicles. Sultan, who arrived afterward, was startled by the silence as bodies were cleared away.

The Turkish-backed fighters, who number around 2,000, have repeatedly entered al-Bab and each time are driven out by the militants, estimated to number around 3,000, said Sultan. "The fighters frankly are afraid of the mines, which cause most of the deaths," Sultan said.

Al-Bab had a prewar population of 60,000 and it's not known how many remain there. Despite the tight IS seal, some still try to escape.

A resident who goes by the name of Abul-Ful for fear for his safety said his sister and her family fled Monday after IS fighters took over their farmland north of the town to use as base. The family of seven moved from one farm to the next undetected until they reached shelter in a village north of al-Bab.

She was lucky, Abul-Ful said. He said his older sister was killed 10 days earlier as she tried to escape with her family. While hiding in farmland, they were caught in crossfire: IS fired on Turkish-backed forces, then moved, and Turkish artillery responded, hitting the family and killing her.

Her family buried her at the spot where she died, then continued their escape, he said.

___

Associated Press writers Suzan Fraser in Ankara, Turkey; Robert Burns in Washington and Vladimir Isachenkov in Moscow contributed to this report.