ISTANBUL — Turkey carried out rare and deadly strikes on Syrian military positions on Monday, after accusing Damascus of killing eight Turkish military personnel in a northern province that has become a flash point for foreign rivalries and the last major battleground in Syria's eight-year war.

The escalation of violence in Idlib province between Turkey and Syria — neighbors but also bitter adversaries — amounted to some of the most serious clashes between the two governments in recent memory.

Fears of an imminent confrontation first surfaced Sunday, after reports that Turkish armored columns had crossed into northwestern Syria. On Monday morning, Turkey’s defense ministry said that four of its soldiers had been killed by Syrian government shelling. And by day’s end, the Turkish death toll had risen to eight, and retaliatory shelling and airstrikes by Turkey had killed dozens of Syrian soldiers, according to Turkish officials.

The eruption of violence was the culmination of tensions over Idlib that had been building for years, analysts said. Syrian President Bashar al-Assad has tried repeatedly to recapture Idlib, the last rebel-held territory in Syria, using tactics, like bombing hospitals and other civilian sites, that human rights groups have said amount to war crimes.

Turkey has tried to stave off an all-out Syrian offensive, to protect its rebel allies in Idlib and to prevent a surge of refugees toward the Turkish border. Russia has tried to stake out a position between the two rivals: by backing Assad on the battlefield, while participating in negotiations with Turkey aimed at de-escalating the violence.

In mid-January, a cease fire — the latest of many — dissolved almost as soon as it was declared, and the long-standing tensions came to a head.

Turkish President Recep Tayyip Erdogan said Monday that the situation in Idlib had become “overwhelming.” Dozens of civilians had been killed by Syrian and Russian airstrikes in recent months, and hundreds of thousands of civilians had fled the Syrian advance. Assad’s government was brutalizing civilians, while Russia turned a “blind eye,” he said.

“We are making them pay the price necessary,” he said, referring to the Syrian government. “We are going to continue to make them pay.”

Erdogan warned last week the Turkish military might act after Syrian forces captured Maarat al-Numan, a key town in Idlib, sending Syrian civilians fleeing en masse farther north. But it was the attack on his soldiers, near the rebel-held town of Saraqeb, that finally prompted Turkey’s military response.

Turkish officials initially said the deaths — of five Turkish soldiers and three Turkish civilian personnel — were caused by shelling. But Erdogan, speaking during a visit to Ukraine on Monday evening, said they had been killed in a Syrian government airstrike.

Russia’s military said in a statement Monday that the Turkish soldiers were caught in crossfire between Syria’s military and unspecified “terrorist groups” after Ankara failed to notify Russia about a Turkish deployment in the area.

“Turkish units were relocated inside the Idlib de-escalation area on the night from February 2 to February 3 without notifying the Russian side and came under fire by Syrian government forces at terrorists west of Saraqeb,” the statement said. Syria’s state news agency said that Turkish soldiers had been killed, without disclosing the circumstances.

But Turkey, which maintains military observation posts across Idlib in coordination with Syria and Russia, insisted Monday that the death of its troops was not some tragic mistake. Russia had been notified about Turkish troop movements at least twice a day earlier, on Sunday, including at 10:27 p.m., Hulusi Akar, Turkey’s defense minister said.

“Despite all these communications and notifications and all these precautions, the regime opened fire” at 1:13 a.m. Monday, he added.

The latest violence appeared certain to further test Turkey’s complicated partnership with Russia. The relationship rests on strengthening commercial and military ties but has recently been strained as the two governments have backed opposing sides in conflicts throughout the Middle East, including in Syria and Libya.

Russia is Assad’s most important military ally and has backed Syria’s Idlib offensive as part of Moscow’s overarching goal of restoring all of Syria’s territory to government control.

Sam Heller, a senior analyst at the International Crisis Group, said Turkey’s troop deployment to Saraqeb appeared aimed at “putting Turkish lives on the line to secure what’s left of the rebel-held Idlib and prevent more masses of vulnerable civilians from rushing toward Turkey.”

Turkey’s government was counting on Syria and Russia’s reluctance “to kill Turkish servicemen as a deterrent. That doesn’t seem to be enough though. Turkey’s move may have complicated and diverted the Syrian military’s advance, but that advance has continued,” he said.

The Syrian army had “flanked” Turkish troops in Saraqeb — “nearly encircling them, and at least eight Turks have been killed by Syrian shelling,” he added.

The Syrian advance, by many accounts, had been merciless. “There’s very intense bombardment from three or four days ago until now, on the entire area,” said Mustafa Haj Youssef, the Idlib director of the civil defense group White Helmets, referring to the town of Saraqeb and surrounding areas.

“Russians are hitting. Syrian military is hitting. Aircrafts are striking. The sound of bombardment is not stopping at all,” he said. “The air force in the sky is not stopping at all.”

He said the civil defense was struggling to cope with the fallout of the bombardment, especially as the strikes had tended to hit the same location two times or more in what are know as “double tap” strikes — a common tactic deployed by Russian and Syrian pilots aimed at maximizing casualties and damage.

Towns and villages have been almost completely emptied out, their residents forced to leave because of the intense shelling. “There are still poor people left who have nowhere to go, no camps, no tents to go to, Haj Youssef added.

“They are being forced to stay under death, under the shelling,” he said. “But at the end, they will have to leave.”

Isabelle Khurshudyan in Moscow contributed to this report.