ANKARA (Reuters) - President Tayyip Erdogan pledged to fight Turkey’s enemies at home and abroad on Sunday as he was elected leader of the ruling AK Party, a move enabling him to reassert his grip on the party and its legislative work.

Erdogan, who founded the Islamist-rooted AKP in 2001 and led it to victory in a general election a year later, had to give up its leadership nearly three years ago when he was elected president, a position traditionally above party politics.

That changed with April’s referendum in which Turks narrowly backed constitutional changes creating an executive presidency with sweeping new powers. Allowing the head of state to be a party member or leader was among the reforms.

Erdogan’s renewed control of the party, which came in a near unanimous vote at an AKP congress where he faced no opposition, coincides with growing foreign policy challenges and tensions with NATO allies.

“Rather than facing our people with our heads down tomorrow, we prefer to stand tall today against the scum at home and abroad,” he told thousands of cheering supporters in the Ankara sports arena.

“The months ahead will be a leap forward for Turkey, from its fight against terrorism to the economy, from the broadening of rights and freedoms to investments,” he said in a brief speech after the vote.

Erdogan vowed to keep Turkey’s state of emergency until peace is achieved against Kurdish and Islamist insurgents.

Slideshow ( 9 images )

He became the first president to lead a party since 1950, taking back the AKP reins from Binali Yildirim, who remains prime minister until elections set for 2019.

Such sweeping political changes, he says, are vital to ensure stability in the face of militant threats and after an attempted coup last year that Ankara attributed to supporters of the U.S.-based cleric Fethullah Gulen.

On the eve of the congress, police killed two suspected Islamic State militants during a raid on an apartment in Ankara, state-run Anadolu news agency reported. The two men killed were believed to be planning an attack, it said.

Opposition parties, which want the referendum annulled because of alleged irregularities, say the reforms push Turkey toward one-man rule. Some of its NATO allies and the European Union, which it aspires to join, have also expressed concern.

TRUMP TALKS

Last week, Erdogan met U.S. President Donald Trump in Washington and sought to reconcile deep disagreement over U.S. support for a Syrian Kurdish militia that Ankara regards as a terrorist group.

Slideshow ( 9 images )

Ties with European Union countries soured in the build-up to the April referendum. Tensions with Germany have been additionally exacerbated by a dispute over the stationing of German troops at Turkey’s Incirlik air base.

Erdogan kept up his fierce criticism of the bloc on Sunday.

“We don’t have to put up with the European Union’s double standards anymore,” he said, demanding the EU keep its word on visa-free travel for Turks, aid for migrants and progress in accession talks if it wants relations to improve.

As party leader once again, Erdogan is expected to streamline his economic team to try to speed up decisions and reassure markets that ministers are working to the same plan, sources said.

In a speech lasting an hour and 45 minutes before the vote, he said he wanted a “serious renewal” of the party by year-end. Nineteen of the AKP’s 50-member executive board were changed on Sunday.

Once regarded as one of the world’s most promising emerging markets, Turkey has been hit by a sell-off of the lira on concerns about the erosion of institutions and the slow implementation of promised change.

Erdogan rejoined the AKP this month, implementing the first of 18 constitutional amendments bolstering his powers. In a second step, lawmakers elected seven members to a reshaped judicial authority on Wednesday.

The other amendments, giving the president authority to draft the budget, declare a state of emergency and issue decrees, will not take effect until after elections scheduled for November 2019.