ISTANBUL — Turkey marked the fourth anniversary of an attempted 2016 military coup Wednesday with ceremonies and memorial events for the people who died in the failed effort to overthrow the government that resulted in the arrests of tens of thousands of people.

Turkish President Recep Tayyip Erdogan, accompanied by civilian "veterans" who fought against the coup, laid a wreath at a memorial in the presidential complex in Ankara and prayed. Erdogan later spoke in parliament and at luncheon and made a televised speech to the nation for the occasion.

Factions within Turkey's military used tanks, warplanes and helicopters to try to overthrow Erdogan's government on July 15, 2016. A total of 251 people were killed and around 2,200 were wounded as renegade service members fired on people and bombed parliament and other government buildings. Around 35 suspected participants in the coup also died.

Turkey has blamed U.S.-based Muslim cleric Fethullah Gulen, a former Erdogan ally, for the coup attempt. Gulen rejects the accusation. The Turksih government designated his network as a terrorist group, and it was dubbed Fethullahist Terror Organization, or FETO.

"We will continue our resolute fight inside our country and abroad until the last FETO member is brought to justice," Erdogan said at a luncheon for relatives of the coup victim's he called "martyrs."

The government declared a state of emergency after the failed coup to crackdown on Gulen's network.

Under emergency powers that were in place for two years, tens of thousands of people were arrested for alleged links to the coup and to Gulen and the trials continue. More than 130,000 people were fired from public service jobs through emergency decrees, among them teachers and police officers.

Critics say the arrests and dismissals went too far, targeting all opposition to the government under Turkey's broad anti-terror laws.

Erdogan said more than 100 people with purported links to the cleric were caught abroad and brought back to Turkey to stand trial. Schools, cultural centers and associations set up across the world by Gulen's transnational network were shuttered or transformed into institutions tied to the Turkish government.

The U.S. hasn't extradited the 79-year-old cleric despite repeated requests.

In his address to the nation, Erdogan also referred to the recent controversy around Hagia Sophia, the former Byzantine cathedral-turned-mosque in Istanbul that Turkey's secular founders made into a museum in 1934. Last week, the top administrative court in Turkey annulled the 1934 decision. Erdogan quickly declared the building would return to use as a mosque and be open to worship later this month.

The decision sparked criticism in the United States, Greece, and other Western countries as well as from Orthodox Christian leaders. Pope Francis expressed sadness over the move.

"We are determined to parry the attacks of terror organizations, just as we raised the call to prayer to the skies from Hagia Sophia 86 years after it was silenced, and like we raised our flag even higher as our sworn enemies tried to bring it down," Erdogan said.

Outside Hagia Sophia on Wednesday, performers dressed in the red Turkish flag's crescent and star staged a choreographed display of shapes commemorating July 15.