The US ambassador to Libya is among four Americans killed in an attack on the US consulate in Benghazi, President Barack Obama has confirmed.
Unidentified armed men stormed the grounds overnight amid uproar among Muslims over a US-produced film said to insult the Prophet Muhammad.
They shot at buildings and threw handmade bombs into the compound.
It has not been confirmed how the ambassador, J Christopher Stevens, and the others died.
Protesters against the film also attacked the US embassy in Cairo on Tuesday night.
The Afghan government gave orders for the video-sharing website Youtube to be closed to the public until the offending film was removed but the site was still visible to internet users in the capital, Kabul.
Speaking at the White House, President Obama told reporters that the attack would not break the bonds between the US and the new Libyan government.
Libya’s interim leader, Mohammed Magarief, apologised to the US over the killings, which he called “cowardly criminal acts”.
Reports say a militia known as the Ansar al-Sharia brigade was involved in the attack, but the group has denied the claim, the BBC’s Rana Jawad in Tripoli says.
Reports suggest that Ambassador Stevens and his staff went to the consulate in an attempt to evacuate the site after it was attacked.
The killing of the US ambassador to Libya, Christopher Stevens, along with three other US embassy staff, raises a host of questions about security, the prevalence of armed militias in the country and the whole trajectory of Libya’s democratic project.
The Obama administration in Washington will want answers from the Libyan government about the scale of the security measures in place at its consulate in Benghazi and how demonstrators were able to get into the building.
More broadly the ambassador’s death highlights the continuing instability in Libya as the country struggles to establish security and the rule of law.
The country is awash with weapons and armed militias – some of a salafist or extreme Islamic fundamentalist outlook – hold sway in many areas.
They were reportedly trying to leave the consulate building for a safer location when gunmen launched an intense attack, apparently forcing back security guards.
“The American ambassador and three staff members were killed when gunmen fired rockets in their direction,” a Libyan official in Benghazi told Reuters news agency.
The Libyan doctor who treated Mr Stevens in hospital said he had died of severe asphyxiation, apparently from smoke inhalation, with no other injuries, and that he had tried for 90 minutes to revive him.
He was the only American brought into the Benghazi Medical Centre and initially nobody realised he was the ambassador, Ziad Abu Zeid told the Associated Press news agency.
A second US man killed in the attack was named as Sean Smith, a father of two who was employed as an information management officer.
The names of the remaining two victims have not yet been released.
US Secretary of State Hillary Clinton described Mr Smith in a statement as “one of the best”.
Speaking to reporters later, Mrs Clinton said many Americans were asking how such an attack could have happened in a country America had helped to liberate.
“This was an attack by a small and savage group, not the people and government of Libya,” she said.
The attack was condemned by UK Foreign Secretary William Hague as “brutal and senseless”.
Our correspondent says many people are still armed following the conflict that overthrew Gaddafi.
Analysts say the attack will raise serious new concerns about stability in the country and the ability of the new Libyan administration to maintain security.
In June, two British bodyguards were injured in an attack in Benghazi on a convoy carrying the British ambassador to Libya. Red Cross and UN staff also came under attack this year.
Correspondents say the film at the heart of the row, which appeared on Youtube translated into Arabic, is highly provocative and insulting to Muslims.
A demonstration in Cairo on Tuesday saw protesters breach the US embassy and tear down the US flag, which was flying at half-mast to mark the 9/11 attacks.
An Islamic tenet bans the portrayal of the Prophet Muhammad.
Cartoons featuring the Islamic religion’s key figure sparked violent unrest among Muslims in 2005 when they were published by a Danish newspaper.
Mrs Clinton said the attack on the consulate in Benghazi “should shock the conscience of people of all faiths”.