(Adds comment by Turkish justice minister)
ANKARA, March 3 (Reuters) - Turkey accused Germany on Friday of scandalous behaviour in cancelling rallies of Turkish citizens in two German towns due to be addressed by Turkish ministers and said Berlin was providing "a shelter" for people committing crimes against Turkey.
The comments by Justice Minister Bekir Bozdag, who was scheduled to address a meeting in the southwestern town of Gaggenau until it was cancelled on Thursday, reflected a broader souring of relations between the two NATO allies.
"Let them look back at their history," he said in a speech. "We see the old illnesses flaring up. They should busy themselves with treating those illnesses."
Foreign Minister Mevlut Cavusoglu told reporters Germany must "learn how to behave" if it wanted to maintain relations.
The Gaggenau meeting would have been part of efforts to garner support among Germany's 1.5 million Turkish citizens for an April referendum on expanding presidential powers, perhaps Erdogan's chief political priority.
Erdogan's relations with Germany have worsened markedly, especially since a July attempt to topple him. He accused West European countries of failing to condemn the putsch quickly or strongly enough. West European countries have expressed concern about his crackdown on coup suspects across Turkish society.
Bozdag, after the cancellation, called off a meeting with his German counterpart and flew back to Turkey. In Ankara, the Turkish foreign ministry summoned the German ambassador for an explanation, ministry sources said.
The city of Cologne also blocked an event where Turkish Economy Minister Nihat Zeybecki was to speak on Sunday amid security concerns.
Authorities in Gaggenau evacuated the city hall on Friday after receiving a bomb threat, its mayor told German television.
Asked by n-tv broadcaster if the threat was linked to the cancellation, mayor Michael Pfeiffer said: "We presume this at the moment, but we don't know for sure."
Turkey itself has been hit by a string of militant attacks over the last year by Islamist militants and Kurdish rebels.
Relations were most recently tested, from the German perspective, by the arrest of Deniz Yucel, a correspondent for the prominent Die Welt newspaper, on Monday.
German Foreign Minister Sigmar Gabriel told reporters in Kiev that the arrest had caused grave damage to ties.
Bozag portrayed Germany as a safe haven for enemies of Turkey, a country of great strategic importance to NATO bordering as it does Syria, Iraq and Iran.
"Germany today has become a shelter for all those who commit crimes against Turkey, the PKK, FETO, DHKP-C members. Those who carried out the coup and everyone who commits crimes against Turkey have fled there," he said.
"This is a decision going beyond the municipality. It is a scandalous decision, contrary to diplomatic niceties."
Erdogan accuses an exiled cleric of masterminding the coup, describing his organisation as the FETO terrorist group. Turkey also complains that Germany and other West European countries give succour to militant leftists and Kurdish militants.
Germany is wary of rising tensions, seeking continued Turkish commitment to procedures preventing large movements of refugees from Turkey to Europe.
Mayor Pfeiffer said that the decision to cancel the event in Gaggenhau was not based on political opposition to Bozdag or the Erdogan government.
"We have freedom of assembly here in Germany, and a right to freedom of expression. Those are high values," Pfeiffer told n-tv. "We are only in a position that we can ban this on security grounds. We don't have a political role." (Reporting by Tulay Karadeniz, Additional reporting by Andrea Shalal, Writing by Ralph Boulton, Editing by Angus MacSwan)