Turkey recently marked the three-year anniversary of the country’s failed July 15 coup attempt, which resulted in hundreds of deaths and almost succeeded in ousting Turkish President Recep Tayyip Erdogan.

Since the coup’s failure, Erdogan has solidified his control over the country—most notably the military and the press—and has turned the anniversary of the coup into a holiday celebrating Turkish nationalism.

This year, as Erdogan waxed poetic about Turkish national pride, he had a concrete symbol of his independence: the first round of deliveries of the controversial S-400 air defense system from Russia, moving forward with a deal that officials and analysts in Washington repeatedly warned would put substantial strain on relations between Turkey and the United States.

It’s a bitterly disappointing end to a long series of signals from Ankara of potential delivery postponements, working groups, and bilateral discussions on the subject. Erdogan, having heard the objections of Congress, multiple Pentagon officials, and Secretary of State Mike Pompeo, has consciously chosen Moscow over the concerns of NATO.

The S-400 system, designed by Russia to shoot down NATO aircraft, poses a clear and present risk to U.S. national security if deployed on Turkish soil, as it could expose the stealth capabilities of U.S.-designed F-35 fighter jets, which Turkey also has contracted to purchase.

President Donald Trump rightly responded on July 17 that the U.S. would immediately halt those F-35 sales, protecting one of the most important instruments of U.S. military power. Sanctions also soon could be imposed on the country under the 2017 Countering America’s Adversaries Through Sanctions Act, which provides a large menu of potential options to penalize countries that buy arms from Russia.

But the U.S. isn’t alone in its frustrations with Erdogan. Last week, he reignited a longstanding conflict over the territorial status of Cyprus, directing Turkish ships to begin energy exploration in Cypriot waters on behalf of a Turkish-led government on the island that only it recognizes.

The European Union, which also was clear in its objections to such a confrontational decision, immediately suspended $154 million in aid to Turkey and asked its investment bank to review hundreds of millions more in current lending to Ankara.

These are just the latest in years of accelerating anti-Western sentiment in Erdogan’s manner and behavior, which has classified him less as an ally and more as a “frenemy” in recent years.

His repudiation of Western interests and values isn’t just a rhetorical tool: Turkey continually has frustrated U.S. strategic objectives in Syria and complicated efforts to mount an international campaign to contain Iran.

He probably sees his defiance of the U.S. and the EU as helping bolster his popularity at home as his political support wanes—most recently and notably in his AK Party’s stronghold city of Istanbul.

Erdogan’s decisions to publicly break with the U.S. and its NATO allies, even as Turkey continues in name as a U.S. ally and maintains its petition for membership in the EU, have led Washington and the EU to levy sanctions against Turkey. The already-struggling Turkish economy will falter further as Erdogan continues to isolate himself from his international partners.

Trump’s expulsion of Turkey from the F-35 deal is a strong and appropriate step that sends a clear message to Ankara and protects U.S. national security.

The Trump administration may impose sanctions against Turkey as well, under the Countering America’s Adversaries Through Sanctions Act, but as the discussion of punitive responses develops, the administration should take care to penalize adverse Turkish policies without breaking NATO ties.

Despite Erdogan’s prickly leadership and increasingly anti-Western tone, Turkey remains an ally on many security issues, and the U.S. air base in Incirlik remains a valuable military asset in the Middle East.

Erdogan won’t rule forever. As much as he would like to remain in power for life, his party’s dramatic Istanbul election defeat shows his political support is declining and he is likely to face greater challenges in future elections.

As lamentable as it is that Ankara has drifted steadily away from the West under his leadership, Erdogan will pass—painfully, like a kidney stone—and a post-Erdogan Turkey should have the opportunity to recommit to its Western alliances instead of being forced into Moscow’s embrace.