A Turkish army tank drives toward the border in Karkamis on the Turkish-Syrian border in southeastern Gaziantep province, Turkey, Aug. 25, 2016. (Umit Bektas/Reuters)

The Turkish government had been planning for more than a year to send troops into Syria to fight the Islamic State before it did so this week, but the intervention was opposed by military officers who later participated in July’s failed attempt to overthrow the government, a senior Turkish official said Thursday.

He spoke as Turkey dispatched additional tanks across the border to reinforce positions around the Syrian town of Jarabulus, which was captured from the Islamic State on Wednesday by Syrian rebels and Turkish troops in Turkey’s first significant foray into Syria since the war began five years ago.

Reluctance within the military to move across the border was reinforced by other issues that subsequently emerged, including Turkey’s November 2015 shoot-down of a Russian jet, which forced Turkey to suspend flights over Syria for fear of Russian retaliation and meant it could not offer air support to any advancing troops.

The suggestion, however, that military officers who were secretly plotting against the government all along had acted for more than a year to thwart its plans to intervene in Syria offers one possible new explanation for President Recep Tayyip Erdogan’s seeming reluctance to fulfill long-standing U.S. demands for Turkey to adopt a more active stance against the Islamic State in Syria.

Planning for the offensive spearheaded by Turkey on Wednesday against the Islamic State-controlled town of Jarabulus began in June 2015, said the official, who spoke on the condition of anonymity in order to share information on sensitive issues. However, the proposals were consistently resisted by the Turkish military, he said.

“Certain commanders within the Turkish military worked hard to stall Turkey’s plan to move against ISIS,” the official said. “Time and again they came up with excuses such as a lack of military capabilities to make it impossible for the government to move forward.”

“A number of [the] staunchest opponents of military action ended up partaking in the coup attempt,” he added.

Among those, he said, was Samih Terzi, head of Turkish special forces, who led an assault in Ankara on the night of the July 15 coup attempt to capture the special forces headquarters. He was shot dead during battles to control the facility.

Turkish special forces, under a new commander, provided the backbone of the Turkish push into Syria, which also involved tanks and Turkish warplanes. The offensive met with no resistance from the Islamic State and the town of Jarabulus was captured within hours — demonstrating, the official said, that “our troops were always up to the task.”

The United States supported the operation with additional airstrikes and advisers — and a statement delivered forcefully during a visit to Ankara by Vice President Biden. The incursion also was made possible by the recent rapprochement between Russia and Turkey, which enabled Turkish warplanes to fly sorties over the battlefield in Syria for the first time since November, the official stressed.

His claims echo frequent complaints made over the past year by U.S. officials that Turkey had seemed unable to follow through with promises to intervene more robustly in Syria. The officials expressed on several occasions their frustration with the discrepancy between the apparent willingness of the Turkish government to send troops into Syria and the reluctance of the Turkish military to endorse the plan.

The ease with which the Turkish-backed Syrian rebel force overran Jarabulus this week may be attributable to the significant weakening over the past year of the Islamic State, which has rapidly been losing ground to a wide range of U.S.-backed forces in Iraq and Syria.

Turkey’s determination to intervene in Syria now also appears to have been fueled by the expanding territorial ambitions of Syria’s Kurds, who have taken advantage of the support they have received from the U.S. military for the fight against the Islamic State to consolidate their control over a newly emerging Kurdish region in northern Syria.

With the swift fall of Jarabulus, the focus now has shifted to the Syrian town of Manbij, 25 miles away, which was captured last week by the Kurdish-dominated Syrian Democratic Forces after an 11-week battle.

Control over Manbij, a mostly Arab town, gives the Kurds a foothold on the west bank of the Euphrates River that would enable them to pursue a declared plan to link up Kurdish-controlled areas of eastern Syria with a small Kurdish enclave in western Syria. That is something Turkish officials have vowed to prevent, for fear that a new Kurdish entity bordering Turkey in Syria would fuel the independence aspirations of Turkey’s already restive Kurds.

The Syrian Kurds said Thursday they had withdrawn from Manbij, fulfilling a key Turkish demand and a promise made to their U.S. backers to do so after they conquered the town. But SDF spokesman Servan Darwish said that Arab and local Kurdish forces affiliated with the SDF would remain there.

Sly reported from Beirut. Heba Habib in Stockholm contributed to this report.