Angela Merkel warned Recep Tayyip Erdogan, the Turkish president, against any attack on free speech or democracy on Thursday as she sought to shore up the fragile European alliance with Turkey.

“Opposition is part of democracy. We see that with one another every day in democratic states,” Mrs Merkel told Mr Erdogan on a visit to Ankara.

Mr Erdogan has come under international criticism for his crackdown on the Turkish opposition since last year’s failed coup attempt.

In a referendum in two months time he is to seek wide-ranging new executive powers critics say could endanger democracy in Turkey.

“At a time of such deep political change, everything must be done to preserve the separation of powers, and above all freedom of opinion and the plurality of society,” Mrs Merkel said.

“During the coup, we saw how the Turkish people stood up for democracy and for the rules of democracy.”

Speaking in Nato’s largest Muslim majority member, Mrs Merkel also hit out at Donald Trump’s Muslim travel ban.

“The fight against terrorism does not justify general suspicion of Muslims,” she said.