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 film produced in the US 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.
Speaking in the Rose Garden at the White House, President Obama told reporters the attack would not break the bonds between the US and the new Libyan government.
But he added: "Make no mistake - justice will be done."
The US is deploying a marine anti-terrorism team to Libya to bolster security after the attack, a US defence source told reporters in Washington.
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.
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".
Mitt Romney, Mr Obama's Republican challenger in the forthcoming presidential election, criticised the US administration's response to the attacks in Benghazi and Cairo, saying it had appeared to "sympathise with those who waged the attacks".
Mr Obama's team, he said, had sent "mixed signals to the world" in the face of violence.
Our correspondent says many people in Libya 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.
On Wednesday, the Afghan government gave orders for 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.
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".