The treatment “of those responsible for the tragic events of last night can and should only be handled according to the rule of law,” she said after the coup bid, which left more than 250 people dead.
Erdogan, who flew back from the holiday resort of Marmaris to a triumphant welcome from supporters at Istanbul's Ataturk Airport, denounced the coup attempt as “treachery”.
Several senior military figures, and a top judge have been detained since the coup attempt, and over 2,500 other judges across the country dismissed
The government also said that almost 3,000 soldiers had been arrested in a major purge of the armed forces.
Prime Minister Binali Yildirim said the plotters were “cowards” who “would get what they deserve”.
Addressing Erdogan but not mentioning him by name, Merkel said that “democracy, which respects everybody's rights and protects minorities, is the best foundation (for the rule of law)”.
Germany stands by “all those who, in Turkey, defend democracy and the rule of law,” she said, adding that political change should only take place through parliament.
Senior European figures echoed Merkel's message, with EU parliament president Martin Schulz stressing that the Turkish government “must not use this occasion to breach democratic rule, restrict freedom of speech and fundamental rights”.
“One-man rule and arbitrary decisions are not acceptable in a country which is not only a strategic ally but also an accession candidate to the European Union,” he said.
Earlier, EU foreign policy chief Federica Mogherini, in a joint statement with the bloc's enlargement commissioner Johannes Hahn, condemned the coup attempt and voiced support for Turkey's “democratic institutions”.
The statement urged restraint from the police and security forces in their response to the coup plotters, “to prevent further casualties”.
“Societal tensions can only be addressed through democratic processes,” Mogherini said.
Last month the EU opened a new negotiating chapter with Turkey in its long-stalled bid for membership, a week after a British vote to leave the bloc in which Ankara's EU aspirations were a major campaign issue.
The decision to revive the process is part of the European Union's migrant deal with Ankara in which it also agreed to boost aid to Turkey to cope with millions of refugees on its territory and to speed up visa liberalisation.
Muslim-majority Turkey formally launched its membership bid in 2005 and since then the EU has opened 15 policy chapters out of the 35 required to join the bloc, although it has only completed one.