The announcement that three soldiers were killed and 10 were wounded heightened the tensions between Syria and Turkey, neighbors with powerful allies. The Syrian government is backed by Russia and Iran. Turkey, a member of NATO, began a major offensive in northern Syria in August as part of its fight against the Islamic State.

Turkey’s prime minister, Binali Yildirim, told Hurriyet, a leading Turkish newspaper, that the attack would “not be left unanswered,” and he said it would not deter his country’s army from its mission in northern Syria.

Mr. Yildirim also reaffirmed the assessment of Turkey’s military chief, Gen. Hulusi Akar, that the attack was carried out by Syrian government warplanes.

Some on the ground raised questions about whether the strike was undertaken by Syrian government forces. A network of activists who monitor the skies over Syria said Thursday that its watchers had spotted a Syrian aircraft taking off after 2 a.m. and also a Russian aircraft about the same time as the strike on Turkish forces occurred. It is impossible to know where the planes that were sighted went; they could easily have had another destination, the network said.

The Syrian Observatory for Human Rights, a network based in Britain that monitors news from Syria, said the strike was by the Islamic State. But the Islamic State, also known as ISIS, is not known to have combat aircraft.

Like Turkey, the Syrian rebels oppose the government of President Bashar al-Assad of Syria.

The Turkish troops had gone into Syria largely to stop an advance by Kurdish rebels, who are also trying to reach Al Bab to dislodge the Islamic State. The Turks see the Kurds as a threat to security as serious as the Islamic State, in part because Kurdish groups inside Turkey have waged a guerrilla war against the government.

Turkey wants to stop the Kurds from reaching the city in part because, if the Kurds succeed, it will enable them to gain a portion of the land between two Kurdish-held areas along the Syrian-Turkish border and increase their potential for joining the regions.