FOR Turkey’s prime minister, Ahmet Davutoglu, May 4th began on a good note. In the morning the European Commission, the European Union’s executive arm, endorsed a proposal to lift visa restrictions for Turks travelling to the bloc’s Schengen zone as of June. For Mr Davutoglu, who had made visa-free travel a key condition for enlisting Turkish help in stemming illegal migration to Europe, the relief was short-lived. By the evening, it was clear the prime minister was out of a job.

The man who pulled the carpet from under his feet was the same one who appointed him less than two years ago: Turkey’s president, Recep Tayyip Erdogan. Tensions between the increasingly authoritarian Mr Erdogan and his prime minister have simmered for months. The two disagreed over the future of peace talks with Kurdish insurgents, and over Mr Erdogan’s plans to change the constitution to give the presidency executive powers, cementing his grip on government and his own Justice and Development (AK) party.

They also clashed over the management of the economy, and Mr Erdogan’s crackdown on critics. (Its latest victims, two journalists, were sentenced to two years in jail last week for republishing a drawing from Charlie Hebdo, a French weekly, featuring a weeping Prophet Muhammad.) Mr Erdogan has accused his prime minister of stealing the spotlight. “During my time as prime minister it was announced that Schengen travel would come into force in October 2016,” he said recently, referring to the visa talks. “I cannot understand why bringing it forward by four months is presented as a triumph.”

Signs that Mr Davutoglu was fighting for his political life emerged last Friday when AK’s executive body stripped him of the right to appoint provincial party officials. Over the weekend, an anonymous blogger believed to be a member of Mr Erdogan’s inner circle suggested that the prime minister had reached his expiry date. Mr Davutoglu, the blogger alleged on a website named “The Pelican Brief”, had crossed his boss by criticising the arrests of academics and journalists and by declining to drum up support for Mr Erdogan’s executive presidency—and by giving an interview to The Economist last year.

On May 5th, a day after the two men met in Mr Erdogan’s 1,100-room palace, AK’s executive council gathered to settle the prime minister’s fate. It was not clear at press time whether he would resign immediately. But in the coming weeks, AK is expected to hold an extraordinary congress to elect Mr Davutoglu’s successor as party leader. Likely candidates include Binali Yildirim, the transport minister, and Berat Albayrak, the energy minister (who also happens to be Mr Erdogan’s son-in-law).

The bookish Mr Davutoglu, a former foreign minister, may have quietly sparred with Mr Erdogan on occasion, but generally tried to play down divisions. His ouster suggests there is no tolerance left for opposition to the president inside his party. It also reveals the price that Mr Erdogan is willing to pay to pursue his agenda. Within hours of his meeting with the prime minister, the Turkish lira plummeted by almost 4% against the dollar, the biggest such drop since 2008. Fears spread that the EU, which had found in Mr Davutoglu a sensible interlocutor and a channel to bypass his abrasive boss, would lose its appetite for engaging with Turkey.

Mr Erdogan appears not to care. No groundwork has been laid for Mr Davutoglu’s departure. To many AK supporters, who saw their prime minister propel the party to a thumping win in elections last autumn, his abrupt ouster seems puzzling. Ozer Sencar, the chairman of Metropoll, a polling company, said it shows Mr Erdogan wants a referendum on his executive presidency this year: “(Mr Davutoglu) presented an obstacle. He had to go.”