YouTube has been banned in Afghanistan to prevent the viewing of a US-made film that sparked an attack on the US Embassy in Benghazi, which left the US ambassador and three others dead.

Many see the movie as being insulting to the Prophet Muhammad.

"We have been told to shut down YouTube to the Afghan public until the video is taken down," Aimal Marjan, general director of Information Technology at the ministry, told Reuters.

There are conflicting reports about which film sparked the anger of the protesters.

One, entitled Muhammad's Trial, the film, which was widely circulated on YouTube, depicts a mock trial of the prophet, and is reportedly linked to controversial Florida pastor Terry Jones, who gained notoriety in the US and throughout the Muslim world for threatening to burn a Koran.

The pastor was also behind “International Judge Muhammad Day”, an online show trial symbolically held on 11 September, in which the Prophet was to "stand trial" before an international audience.

Another film, Innocence of Muslims, posted on YouTube, was also cited as the cause of the violence.

The US ambassador to Libya, Christopher Stevens, and three other embassy staff were killed in a rocket attack in the eastern Libyan city of Benghazi overnight on Tuesday.

One of the other three Americans killed was identified as Foreign Service Information Management Officer Sean Smith, the White House confirmed.

A tweet, from the account of the deputy prime minister of Libya, described the attacks as "cowardly".

The Libyan official said Mr Stevens had been trying to make his way to safety after protesters tried to storm the consulate in Benghazi and opened fire, killing a staff member, in protest at the YouTube film.

ALSO SEE: US Ambassador Chris Stevens 'Killed In Benghazi Rocket Attack' After Protests Over Muhammad YouTube Video
Loading Slideshow...
  • Protesters chant slogans amid orange smoke outside the U.S. embassy in Cairo, Egypt, Tuesday, Sept. 11, 2012. Egyptian protesters, largely ultra conservative Islamists, have climbed the walls of the U.S. embassy in Cairo, went into the courtyard and brought down the flag, replacing it with a black flag with Islamic inscription, in protest of a film deemed offensive of Islam. (AP Photo/Mohammed Abu Zaid)

  • Protesters chant slogans amid orange smoke outside the U.S. embassy in Cairo, Egypt, Tuesday, Sept. 11, 2012. (AP Photo/Mohammed Abu Zaid)

  • Protesters destroy an American flag pulled down from the U.S. embassy in Cairo, Egypt, Tuesday, Sept. 11, 2012. (AP Photo/Mohammed Abu Zaid)

  • Protesters chant slogans outside the U.S. embassy in Cairo, Egypt, Tuesday, Sept. 11, 2012. (AP Photo/Mohammed Abu Zaid)

  • Protesters chant slogans amid orange smoke outside the U.S. embassy in Cairo, Egypt, Tuesday, Sept. 11, 2012. (AP Photo/Mohammed Abu Zaid)

  • Protesters destroy an American flag pulled down from the U.S. embassy in Cairo, Egypt, Tuesday, Sept. 11, 2012. (AP Photo/Mohammed Abu Zaid)