Turkey on Monday blocked access to social networking sites, including Twitter and YouTube, over photos showing a militant pointing a gun at a prosecutor who died last week in a failed hostage rescue operation. Access to Twitter was restored several hours later.

A spokesman for President Recep Tayyip Erdogan said a Turkish prosecutor had ordered Internet providers to block the sites. The request stemmed from postings of photos that showed militant Marxists pointing a gun at the prosecutor, Mehmet Selim Kiraz, who died in a shootout between police and the Marxists who were holding him hostage.

Government officials have blasted Turkish media for posting the images, which they have called anti-government propaganda. Kiraz, was shot in the head during the standoff and died in a hospital soon after.

The state-run Anadolu Agency said access was blocked because Twitter and YouTube didn't remove images of the prosecutor despite an official notification. It said the Internet Providers notified Twitter and YouTube, but video, photographs and audio continued to be posted on these sites. The Turkish telecommunications authority wouldn't immediately comment.

A government official said Turkey decided to lift the ban on Twitter in the late afternoon after the company agreed to remove all images of the prosecutor and telecoms authorities verified that it had done so. The official spoke on condition of anonymity because she was not authorized to speak publicly on the issue.

Twitter said earlier that it was working to restore access to users in Turkey.

"We are aware of reports of interruption of our service in Turkey, and we are working to restore access for our users as soon as possible," the company said in Turkish and in English through its (at)policy account.

The journalists group, Turkish Press Council, said that while it understood the authorities concerns over the publication of the prosecutors' photographs, it said banning social media websites was in conflict with democracy.

"It is meaningless to totally shut down social platforms -- which contain billions of useful information -- to the use of the Turkish people because of some unsuitable content," the group said.

Users meanwhile were sharing information on how to get around the ban on the Internet.

Last year, Turkey blocked access to YouTube and Twitter after audio recordings of a secret security meeting or tapes suggesting corruption by government officials were leaked on the social media sites. Turkey's highest court, however, overturned the bans, deeming them to be unconstitutional.

Previous moves by Turkish authorities to block the social media networks have provoked widespread criticism by Western governments and human rights organizations.

Many tech-savvy users, including former President Abdullah Gul, had found ways to circumvent the bans both on Twitter and YouTube while they were in place.