The two nations have clashed over numerous issues in recent years, including Turkey's jailing of German journalists and a German parliament resolution labeling the early-20th century killing of Armenians in Turkey as genocide. Turkey vehemently denies that the massacre was genocide and insists it was part of the violence during World War I.
The rhetoric escalated to the point where Erdogan called Germany's mainstream parties "enemies of Turkey" and accused German officials of acting like Nazis, prompting Merkel to condemn the Turkish president's comments.
Erdogan ignored a question Friday about whether he had apologized for the Nazi comment. He instead doubled down on his demand for closer cooperation from Germany against groups that Turkey considers terrorist organizations, including Kurdish rebels and people with alleged links to a failed 2016 coup in Turkey.
Erdogan alleged that thousands of Kurdish militants and hundreds of people with suspected links to U.S.-based Muslim cleric Fethullah Gulen are living in Germany. Turkey accuses Gulen of orchestrating the coup attempt, which he denies.
"With the mutual trust we have for each other, I believe the handing over of (suspects) would make our work easier," Erdogan said. Merkel noted that Germany considers the PKK Kurdish rebel group a terrorist organization and prosecutes its members, and said German authorities take Erdogan's information on Gulen seriously "but we need more material — what we have is not enough for a similar status to the PKK."
She also criticized the Turkish prosecution of journalists and others, detaining some for months without charges. "It is no secret to anyone that there have been deep differences in our relationship in recent years, and that there still are," she said. "That largely has to do with questions of the rule of law, with questions of press freedom."
Erdogan said he has no right to criticize the German judiciary and Germany has no right to criticize the Turkish judicial system. The trip is Erdogan's first formal state visit to Germany, home to more than 3 million people with Turkish roots. But the increasingly authoritarian leader is viewed with suspicion across the political spectrum in Germany.
At the same time, the two countries recognize mutual strategic interests, with Turkey being key to the European Union's strategy to slow the flood of migrants into the continent. Turkey, which has a struggling economy, also needs economic cooperation from Germany and other European nations.
Merkel said she and Erdogan talked about bilateral economic cooperation and stressed that "Germany has an interest in an economically stable Turkey." "There is, on the one hand, a common strategic interest in good relations, and on Germany's part too an interest in developing these relations," she said. "But on the other hand, on all questions of how a democratic, free and open society looks, there are also deep misunderstandings — not misunderstandings, differences."
"I think this visit is significant because we can only clear up differences by talking to each other," she said. Before the news conference, exiled Turkish journalist Can Dundar, the former editor of Turkey's opposition Cumhuriyet newspaper, said he had decided not to attend after learning that Erdogan was considering canceling the news conference if he were present.
Asked about Dundar, who was convicted by Turkey in 2016 of revealing state secrets after his newspaper published photographs suggesting that Turkey's intelligence agency was involved in sending weapons to Syrian rebels, Erdogan called him a "convicted spy" who should be extradited.
Merkel said she didn't want to discuss specifics, but that it was "no secret" that Turkey and Germany differed in the case of Dundar, who fled to Germany. As the leaders talked, another Turkish journalist who lives in Germany, identified by the dpa news agency as Ertugrul Yigit, stood up wearing a T-shirt with the slogan "Freedom for Journalists in Turkey." He was quickly removed by guards.
At a state banquet later Friday that many German opposition politicians skipped, German President Frank-Walter Steinmeier voiced concerns about the Germans held in Turkey, as well as "Turkish journalists, unionists, jurists, intellectuals and politicians who are still in custody."
That drew a sharp rejoinder from Erdogan, who said "it is not our job to protect terrorists," according to an interpreter. He complained about members of what Turkey considers terrorist groups "running around free" in Germany — "and we're not supposed to talk about that?"
Several thousand people demonstrated against Erdogan in Berlin on Friday night amid tight security. More protests were expected Saturday in Cologne, where the Turkish president will be opening a new mosque.
Geir Moulson in Berlin and Suzan Fraser in Ankara, Turkey, contributed to this story.