ANKARA/ISTANBUL (Reuters) - President Tayyip Erdogan on Sunday defiantly stepped up his attacks on the European Union, saying Turkey had to go its own way and vowing to bring back the death penalty if parliament passed it.

At the opening ceremony of a memorial dedicated to the roughly 250 people who died in last year’s failed coup, Erdogan accused Brussels of “messing about” with Turkey’s decades-long bid to join the bloc.

The speech in the early hours of Sunday wound up a marathon session of public appearances by Erdogan in both the capital and Istanbul overnight to mark the anniversary of last year’s defeated coup.

“The stance of the European Union is clear to see ... 54 years have passed and they are still messing us about,” he said, citing what he said was Brussels’ failure to keep promises on everything from a visa deal to aid for Syrian migrants.

“We will sort things out for ourselves. There’s no other option.”

Ties with the West were strained when European governments voiced alarm at the scale of the crackdown that followed the coup. Some 150,000 people have been sacked or suspended from their jobs and more than 50,000 detained on suspicion of links with the U.S.-based Muslim cleric Fethullah Gulen, whom Ankara blames for the attempted putsch.

Erdogan also said he would approve, “without hesitation” the death penalty, if parliament voted to restore it -- a move that would effectively end Turkey’s bid to join the EU.

“I don’t look at what Hans and George say. I look at what Ahmet, Mehmet, Hasan, Huseyin, Ayse, Fatma and Hatice say,” he said, to cheers from a flag-waving crowd.

Erdogan, the most popular and divisive politician in recent Turkish history, sees himself as the liberator of pious millions who were deprived for decades of their rights and welfare by the secular elite.

The coup’s defeat has likely ended decades of military interference in Turkish politics. But the purges have sharpened the divide between Erdogan’s supporters and Western-facing Turks who want closer ties with Europe.

‘SLAM THE DOOR’

Critics say Erdogan is using a state of emergency introduced after the coup to target opposition figures including rights activists, politicians and journalists.

More than a dozen members of the pro-Kurdish Peoples’ Democratic Party (HDP) - including its two co-leaders - are in jail, as well as local members of rights group Amnesty International.

Slideshow ( 19 images )

The New York-based Committee to Protect Journalists calls Turkey the world’s biggest jailer of journalists, with some 160 now detained. Leftist, pro-Kurdish and opposition media outlets have also been shut.

Authorities on Saturday detained the editor of a local newspaper over a column criticizing the aftermath of the failed coup, her newspaper said.

In the run-up to the anniversary, Turkish media has been saturated by coverage from the coup attempt, with some channels showing almost constant footage from last year of young men and headscarved mothers facing down armed soldiers and tanks.

Slideshow ( 19 images )

On Saturday, mobile phone networks played a 13-second pre-recorded message from Erdogan before connecting calls. In the message he honored the “martyrs” who died during the coup attempt and those “veterans” who took to the streets.

‘RIP THE HEADS OFF’

European Commission chief Jean-Claude Juncker said the EU remained committed to dialogue with Turkey and called on Ankara to strengthen democracy and the rule of law. He also warned against reinstating the death penalty.

“One year after the attempted coup, Europe’s hand remains outstretched,” Juncker wrote in Germany’s Bild am Sonntag newspaper.

“If Turkey were to introduce the death penalty, the Turkish government would finally slam the door to EU membership.”

Addressing a crowd of hundreds of thousands in Istanbul on Saturday evening, Erdogan threatened to wreak violent retribution on Turkey’s enemies, including FETO - his term for Gulen’s network - and the outlawed Kurdistan Workers Party (PKK).

“We know who is behind FETO, the PKK and all of them,” he said. “We cannot defeat the queen, king, or sheikhs without defeating the pawns, knights and castles. Firstly, we will rip the heads off of these traitors.”

He also said that alleged members of Gulen’s network would be forced to wear jumpsuits like those worn by prisoners at the Guantanamo Bay detention camp, after one detainee showed up to a court hearing wearing a T-shirt that said “Hero”.