Europe's hopes of containing the migrant crisis were thrown into sudden doubt on Wednesday night amid reports that Ahmet Davutoglu, the Turkish prime minister, was to be ousted by the country’s increasingly authoritarian and erratic president.

Mr Davutoglu, the mild-mannered architect of a €6 billion (£4.7 billion) aid-for-deportations deal with Germany that has cut the flow of boats to a trickle will be replaced at an emergency congress this month, Turkish TV said. He will hold a press conference on Thursday.

He appears to have lost a power struggle with Recep Tayyip Erdogan, the president who had little role in the migration deal, but who has publicly goaded European leaders with lurid threats to “open the gates” and flood Europe with refugees unless leaders handed over billions in aid.

The two men have disagreed over relations with Europe as well as the detention of government critics. Tensions spilt over in recent days with the arrival of the Pelican Brief - a reference to the 1993 Hollywood film - blog on May 1.

A blog post - which praised Mr Erdogan as "CHIEF" - several times accused Mr Davutoglu of being a traitor. For many analysts in Turkey, Mr Davutoglu's days were numbered after the website went live.