Libya's deputy U.N. ambassador on Wednesday blamed "an extremist group" for the attack on the U.S. Consulate in Benghazi that killed U.S. Ambassador Chris Stevens, whom he called "one of the greatest friends of Libya."

Three other American diplomats and several Libyan security officers were also killed in the attack Tuesday night.

Speaking to the U.N. Security Council, Ibrahim Dabbashi reiterated his government's vow that the perpetrators will be brought to justice.

According to Libyan officials, the assault was carried out by protesters angry over a film that ridiculed Islam's Prophet Muhammad.

"This attack in no way serves the interests of the people or the Libyan authorities, and cannot be considered a defense of Islam," Dabbashi told the hushed chamber. "Moreover, this attack gravely damages the image of Islam."

The Security Council and U.N. Secretary-General Ban Ki-moon later condemned the attack "in the strongest terms."

Stevens, 52, was killed when he and a group of U.S. Embassy employees went to the consulate to try to evacuate staff as the building came under attack by a mob armed with guns and rocket propelled grenades.

The Security Council said that in addition to those killed, "diplomatic personnel and civilians" were injured but gave no numbers. Dabbashi said a number of Libyan security officials were wounded.

He said the attack was "carried out by an extremist group acting outside the law" and the government is trying to gather the facts, and determine how it was prepared and who was behind it. He said he didn't have details about whether any of the attackers were captured, "but certainly I presume some of them are already in prison and they are trying to bring all the others to justice."

Dabbashi was visibly moved talking about Stevens, saying the ambassador stood by the Libyan opposition in its fight to oust longtime dictator Moammar Gadhafi last year.

"He was very brave in staying in Benghazi to see on the ground what was happening," Dabbashi said.

"He tried very sincerely to promote relations between the two countries and to help Libyans move from revolution to their new state, and for this reason we will always remember ambassador Stevens as being one of the greatest friends of Libya," he said.

The deputy ambassador was asked to respond to U.S. Secretary of State Hillary Rodham Clinton, who asked earlier Wednesday how Stevens could be killed in a country that the United States helped to liberate.

"We have the same question," Dabbashi replied. "We have to say the reality — that the authority of the government is still not covering the whole territory of Libya and there are some groups and persons who are outlaws, and the government could not at this moment contain all of them."

"However, this is a provisional period, and the Libyan people are determined to extend the authority of the state throughout the country and to form a strong government that will be able to manage the country and bring it from revolution to a state," he said.

By coincidence, the Security Council had scheduled a meeting Wednesday to discuss Ban's latest report on the U.N. political mission in Libya.

The report said Libya is facing a resurgence of several local conflicts and increased instability in the east, whose capital is Benghazi. It also said the country faces "huge challenges" in trying to secure its borders and control a proliferation of weapons.

U.N. Undersecretary-General for Political Affairs Jeffrey Feltman, a former American diplomat and close friend of Stevens, told the council that in Benghazi on Tuesday "the world witnessed a sobering reminder of the challenges faced not only by the Libyans but by the international community who are committed to support Libya's ongoing transformation."

In addition to the latest attack, he noted a spate of previous assassinations of Libyan security personnel in Benghazi, a series of explosive devices in Tripoli and attacks on Sufi shrines.

In a statement, the U.N. Security Council also condemned an attack on the U.S. Embassy in Cairo. The U.N.'s most powerful body urged Libyan and Egyptian authorities to bring the perpetrators to justice and ensure that diplomatic premises and personnel are protected as required by the Vienna conventions.

Ban made a similar appeal.

"The United Nations rejects defamation of religion in all forms," the secretary-general in a statement released by his spokesman. "At the same time, nothing justifies the brutal violence which occurred in Benghazi yesterday."

Coinciding with Wednesday's Security Council meeting, the secretary-general announced the appointment of former Lebanese minister Tarek Mitri as his new special representative in Libya, succeeding Ian Martin of Britain who will complete his assignment on Oct. 14. Mitri, who worked for the World Council of Churches in Geneva from 1991-2005, most recently held academic posts at Saint Joseph University in Beirut and the American University in Beirut.