ISTANBUL — President Recep Tayyip Erdogan has marked the anniversary of a failed coup against him every passing year — this week was the third — with a national holiday that has turned the traumatic event into a celebration of Turkish nationalism.

But this year, Mr. Erdogan had even more to cheer about, as he flaunted an extra-special symbol of national pride, the S-400 missile defense system that had just arrived from Russia.

“As long as we, as a nation, protect our homeland, our flag, the call for prayer, democracy and the state,” he declared at a ceremony at Ataturk Airport Monday, “God willing, no power’s hand will be able to reach them.”

Over his 17 years in power, Mr. Erdogan has tried to recast Turkey as a stronger, more independent actor on the international stage, one that in his view can vie toe to toe with powers like China, Russia, the European Union and the United States.