Berlin — which sees Turkey's bid to have the writer extradited as a politically-motivated move by President Recep Tayyip Erdogan — hailed the Spanish court's decision.
“It would be terrible if, even on the other side of Europe, Turkey succeeded in having people who raise their voices against President Erdogan arrested,” said German Foreign Minister Sigmar Gabriel.
Gabriel, who had discussed the case with his Spanish counterpart Alfonso Dastis on Saturday, said he had “the utmost confidence” in the Spanish judiciary and that the government in Madrid “knows what this is about”.
Spanish police had on Saturday arrested Akhanli, who writes about Turkey's human rights record, while he was on holiday in Granada after receiving a so-called Interpol red notice, which is similar to an international arrest warrant.
Berlin quickly urged Madrid not to extradite Cologne-based Akhanli, who has previously been jailed in Turkey and was granted political asylum and citizenship in Germany.
Writing on Facebook, Akhanli's lawyer Ilias Uyar said his client was “being released from detention on condition he stays in Madrid” while Turkey starts the process of formally requesting his extradition.
“The battle was worth it,” the lawer wrote.
Akhanli has written about the highly sensitive historical question of the mass killing of Armenians under the Ottoman Turkish empire.
Half a million to 1.5 million Armenians were killed between 1915 and 1917, in a bloodletting that Armenia and Western historians describe as genocide.
Turkey vehemently objects to the term, saying that 300,000 to 500,000 Armenians and as many Turks died in civil strife when Armenians rose up and sided with invading Russian troops.