President Recep Tayyip Erdogan pledged to fight Turkey's enemies at home and abroad on Sunday as he was re-elected leader of the ruling AK Party. This makes him the first Turk in nearly 70 years to serve simultaneously as head of state and of a political party.

"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 rapturous supporters who gathered for an AKP congress, where he is the only leadership candidate.

"We will continue our battle against all terrorist organisations," he said in the Ankara sports arena, vowing to maintain a state of emergency in Turkey until peace is achieved in Turkey's fight against armed groups.

READ MORE: Turkey to extend state of emergency by three months

Erdogan, who founded the AKP in 2001 and led it to victory in an election a year later, was forced to surrender leadership nearly three years ago when he was elected president, a position traditionally above party politics.

That changed with last month's referendum, in which Turks narrowly backed a constitutional change to create an executive presidential system that will give Erdogan sweeping new powers and allow the head of state to be a party member or leader.

He will be the first president to lead a party since Ismet Inonu, who succeeded modern Turkey's founder, Mustafa Kemal Ataturk, and was head of state until 1950.

In a vote on Sunday, he replaced Binali Yildirim, who is set to remain as prime minister until elections in 2019.

Such sweeping political changes, Erdogan says, are vital to ensure stability in Turkey in the face of threats from armed groups and after an attempted coup last year that Ankara attributed to supporters of US-based cleric Fethullah Gulen.