YouTube and Twitter were inaccessible from Turkey for hours on Monday, although the ban on Twitter lifted late in the evening.
The prosecutor seen in the pictures, Mehmet Selim Kiraz, was later killed in a shoot-out between his hostage takers and police last week.
A spokesman for President Tayyip Erdogan said a prosecutor had demanded the bans because some media organisations had acted “as if they were spreading terrorist propaganda” in sharing the images of the hostage-taking.
It claimed it was upset because the media was using a picture of the terrorists holding a gun to Kiraz’s head, which was upsetting to the dead man’s family.
Facebook said it had restricted access to some content as instructed and a company spokesman said it would appeal the order.
In the end everyone did what they were told and the ban was lifted.
The Turkish government is not a fan of social media platforms. Last year, just before the local elections, access to Twitter and YouTube were also banned.
The then prime minister, now President Recep Tayyip Erdogan, said that Twitter was a menace to society.