WASHINGTON — One might wonder how a country that recently survived a bloody coup attempt and multiple terrorist attacks could embark on a military incursion into a neighboring country. Yet this is exactly what Turkey has done.

In the early hours of Wednesday, Turkey sent tanks and warplanes across the border into Syria in a coordinated campaign with Western-backed Syrian opposition fighters to capture the town of Jarabulus, one of the Islamic State’s last strongholds on the Turkish border, which the Foreign Ministry had recently vowed to “cleanse” of the militant group.

But the operation seems to be aimed more at containing the territorial ambitions of the Syrian Kurds, which Turkey sees as its primary enemy in Syria.

Turkey views the Syrian Kurdish militia, the People’s Protection Units, or Y.P.G., as an extension of the outlawed Kurdistan Workers’ Party, a militant group that has been at war with the Turkish state for decades. It’s true that there are close ties between the groups. But it’s also true that in recent years, the Y.P.G. has become Washington’s most effective ally fighting against the Islamic State on the ground in Syria.