Updated

A teenager has been released from custody after his arrest for allegedly insulting Turkish President Recep Tayyip Erdogan caused uproar in the country.

The 16-year old student, identified by his initials M.E.A, was taken away from his school on Wednesday and jailed for making a speech during a student protest in which he reportedly said Erdogan was regarded as the "thieving owner of the illegal palace." It was a reference to a government corruption scandal as well as a controversial 1,150-room palace Erdogan inaugurated in October.

A court in the central Turkish city of Konya agreed to free the boy from police custody on Friday, after dozens of lawyers petitioned for his release.

He still faces up to four years in prison if charged and convicted of insulting Erdogan.