A Turkish teenager who was arrested on Wednesday for allegedly insulting the president has been released.
A court freed the 16-year-old, listed only by the initials MEA, but he still faces trial and a possible four-year sentence if found guilty.
He was arrested after criticising the ruling Islamic-rooted AK Party during a speech in the central city of Konya.
The opposition condemned the arrest but PM Ahmet Davutoglu defended it, saying that respect had to be shown.
"Everyone must respect the office of president whoever he is," Mr Davutoglu said.
Turkey's penal code makes it a crime to insult the president.
As he left the courthouse in Konya, the boy said: "There is no question of taking a step back from our path, we will continue along this road."
There has been growing concern amid rights groups in Turkey at what they see as a clampdown on freedom of speech.
The boy was arrested at school on Wednesday and taken for questioning.
His speech, given to commemorate the killing of a Turkish soldier by Islamists in the 1920s, was recorded on video and broadcast by Dogan News Agency.
In it, he defended secularism and the principles of Mustafa Kemal Ataturk, the founder of the modern Turkish republic.
He reportedly called Mr Erdogan the "thieving owner of the illegal palace", referring to a controversial 1,150-room palace inaugurated by the president in October.
Speaking to prosecutors, the boy said: "I've made the statement in question. I have no intent to insult."
He denied being linked to any political movement.
His release came after dozens of lawyers had signed a petition on his behalf. He was met by his parents at the courthouse.
The arrest sparked fierce criticism of Mr Erdogan, with Attila Kart, a member of opposition party CHP, saying the president was creating "an environment of fear, oppression and threat".
Mr Erdogan, who was elected president in August after serving as prime minister for 11 years, has faced several corruption allegations in recent years.
He insists they are baseless and part of a "dark plot" to oust him from power by influential cleric Fethullah Gulen, who is in self-imposed exile in the US.
Earlier this month, police arrested more than 20 journalists working for media outlets thought to be sympathetic to the Gulen movement.