Turkey's prime minister has resigned, paving the way for his replacement by a trusted ally of President Recep Tayyip Erdogan.

Mr Erdogan's office said Ahmet Davutoglu quit hours after the ruling party confirmed transport and communications minister Binali Yildirim as its new chairman at an extraordinary party convention.

Mr Yildirim immediately expressed allegiance to the Turkish leader and vowed to follow his path.

Mr Erdogan is to formally ask Mr Yildirim to form a new government but Mr Davutoglu remains caretaker prime minister until that happens.

Mr Davutoglu announced earlier this month that he was stepping down amid differences with Mr Erdogan.

Mr Yildirim is widely expected to be more in tune with the president, who is pushing for an overhaul of the constitution that would give the largely ceremonial presidency executive powers.

"Our path is the path of the voice and the breath of the people, our party's leader, Recep Tayyip Erdogan," said Mr Yildirim in his speech.

He thanked delegates who voted overwhelmingly to endorse him as the new chairman of the governing Justice and Development Party, or AKP.

Mr Yildirim, a founding member of the AKP, also paid homage to the president in an earlier speech and made clear he intends to work towards introducing a new constitution that would change Turkey's political system into a presidential one.

He said the "de facto situation" would turned into a "legal" one.

"We have always proudly said that we are Recep Tayyip Erdogan's companion, that we share a common fate and a common passion," said Mr Yildirim.

"Mr President, we promise you that your passion will be our passion, your cause will be our cause, your path will be our path."

In a message read at the opening of the convention, Mr Erdogan again stressed the need for a new constitution and a new system of government.

He said he hoped the term ahead would help correct the current "skewed" system of administration, and delegates and party officials stood up as his message was read.

"My legal bond with the AKP may have ended the day I took the (presidential) oath of office, but my bonds of love have never ended and never will," said Mr Erdogan.

Supporters credit Mr Yildirim, 60, for his role in developing major infrastructure projects which have helped buoy Turkey's economy and boost the party's popularity.

But critics, including the leader of the main opposition party, have accused him of corruption, although Mr Yildirim rejected the accusation.

The change in party leadership comes at a time when Nato member Turkey faces an array of security threats.

These include renewed conflict with Kurdish rebels in the south east, a wave of suicide bombings linked to Kurdish and Islamic State militants, and a growing blowback from the war in neighbouring Syria.

The transition also coincides with growing tensions with the European Union over a controversial deal to reduce the flow of illegal migrants from Turkey to Greece, which Davutoglu helped broker.

Mr Davutoglu, a one-time adviser to Mr Erdogan and a former foreign minister, fell out with the president over a range of issues.

These included the possibility of peace talks with Kurdish rebels, and the pre-trial detention of journalists accused of spying and academics accused of supporting terrorism.

The president is pushing for a broader definition of terrorism, alarming rights groups who say existing laws are already too widely interpreted to crush dissent.

His stance is also at odds with EU conditions for Turkish citizens to benefit from visa-free travel.

Crucially, Mr Erdogan wants to turn the figurehead presidency into an all-powerful position while the independent-minded Mr Davutoglu was believed to be less than enthusiastic towards that project. Many believe Mr Yildirim will work to push Mr Erdogan's agenda through.

In his speech, Mr Yildirim said Turkey would press ahead with operations against Kurdish rebels until the group's armed campaign comes to an end.

He also called on the EU to end "the confusion" over Turkey's membership bid and the migration deal.

"It is time we know what they think about Turkey," Mr Yildirim said.

"Whether Turkey becomes a member or not, it will continue to expand its democracy and development with determination."

In his farewell speech, Mr Davutoglu said resigning was not his wish but that he agreed to it to preserve the unity of the party.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.