ISTANBUL - Turkish President Recep Tayyip Erdogan lashed out at the German government on Saturday for criticising his call to ethnic Turks to vote against Germany’s two ruling parties in September elections, warning the foreign minister to “know your limits”.

The latest spat between Ankara and Berlin risks propelling a months-long crisis in ties between two NATO allies with deep historic links to a new level ahead of Germany’s general election on September 24.

Erdogan had a day earlier caused consternation in Berlin by urging ethnic Turks in Germany to vote against both parties in Chancellor Angela Merkel’s governing coalition.

Foreign Minister Sigmar Gabriel had bitterly condemned Erdogan’s comments as an “unprecedented act of interference” in Germany’s sovereignty.

But speaking to supporters in the southwestern province of Denizli, Erdogan launched a stinging personal attack on Gabriel.

“He knows no limits! Who are you to talk to the president of Turkey? Know your limits. He is trying to teach us a lesson... How long have you been in politics? How old are you?” Erdogan said.

Erdogan repeated his controversial call for ethnic Turks eligible to vote in the German elections not to cast their ballots for Merkel’s Christian Democratic Union (CDU), their coalition partner the Social Democratic Party (SPD), or the Greens.

“Teach them a lesson in the German elections,” he said. “They are waging a campaign against Turkey. Vote for those who don’t have enmity towards Turkey.”

He added: “It’s not important for us whether Germany opens its doors to us or not. We have enough doors.” Tensions have spiralled between Germany and Turkey in recent months.

Berlin has lambasted Ankara over the magnitude of the crackdown that followed last year’s failed coup, which has seen several German citizens arrested, including journalists. Turkish-German journalist Deniz Yucel, the Istanbul correspondent of the Die Welt daily, has been jailed in Turkey since February ahead of trial on terror charges.

German journalist Mesale Tolu has been held on similar charges since May, while activist Peter Steudtner was arrested in a July raid.

Ankara meanwhile has accused Berlin of failing to extradite suspected Kurdish militants and coup plotters who have taken refuge in Germany.

Addressing Merkel as “Madam”, Erdogan said the Turkish authorities had sent Germany dossiers on 4,500 suspects wanted for extradition to Germany on terror charges and received no answer.

“And she wanted one or two people to be sent home by me,” he said in apparent reference to the detained journalists and activist. “Forgive me but you have your legal system and so do we,” he added.

In a potential further bone of contention, Dogan Akhanli, a German writer of Turkish origin who has written extensively on Turkey’s human-rights record, was arrested in Spain on Saturday at Ankara’s request, Greens MP Volker Beck said. It was not clear why.

Earlier, Turkish Deputy Prime Minister Bekir Bozdag, who is also the official government spokesman, defended Erdogan’s comments and said the reactions were “very disrespectful and very arrogant” and “beyond the bounds of decency.”

Gabriel’s SPD - whose candidate for the chancellorship is ex-EU parliament speaker Martin Schulz - and Merkel’s CDU are rivals in the election. But they have been in broad agreement on the policy regarding Turkey within the country’s grand coalition.

Merkel’s spokesman Steffen Seibert said on Twitter: “We expect foreign governments to not interfere in our internal affairs.”

The opposition Greens meanwhile have pushed for an even tougher line against Ankara, with its co-leader Cem Ozdemir, who is himself of Turkish origin, a vocal critic of Erdogan. Ankara Mayor Melih Gokcek, a staunch Erdogan loyalist, lashed out against Ozdemir on Twitter, warning: “Sit tight! You Armenian servant...”

Ozdemir had previously pressed Ankara to recognise the World War I killings of Armenians as genocide.

Analysts estimate that about 1.2 million people of Turkish origin will have the right to vote in the September elections.