The US ambassador to Libya and three embassy staff were killed in an attack on the Benghazi consulate and a safe house refuge, stormed by Islamist gunmen blaming America for a film they said insulted the Prophet Mohammad.

They attacked and set fire to the US consulate in the eastern city of Benghazi – the cradle of last year's uprising against Muammar Gaddafi's 42-year rule – late on Tuesday evening as another assault was mounted on the US embassy in Cairo.

California-born ambassador Christopher Stevens was killed in the assault. US consular staff were rushed to a safe house after the initial attack, Libya's Deputy Interior Minister Wanis al Sharif said.

An evacuation plane with US commandos units then arrived from Tripoli to evacuate them from the house.

"It was supposed to be a secret place and we were surprised the armed groups knew about it. There was shooting," Mr Sharif said. Two US personnel were killed there, he said. Two other people were killed at the main consular building and between 12 and 17 wounded.

The amateurish film, promoted by a US pastor, portrayed Mohammad as a fool, a philanderer and a religious fake. In one clip posted on YouTube, Mohammad was shown in an apparent sex act with a woman.

US President Barack Obama, whose administration supported the Libyan insurgency with funds, weapons and training, branded the killing an "outrageous attack" and ordered increased security at US diplomatic posts worldwide.

US Secretary of State Hillary Clinton said the attack was the work of a "small and savage group".

Descriptions of the consulate attack described chaos and bloodshed, with Libyan security over-run and retreating.

"We started shooting at them, and then some other people also threw hand-made bombs over the fences and started the fires in the buildings," said 17-year-old Hamam, who took part in the assault and refused to give his last name.

"There was some Libyan security for the embassy outside but when the hand-made bombs went off they ran away," said Hamam, who added he saw an American die in front of him in the mayhem that ensued.

The attack was believed to have been carried out by Ansar al-Sharia, an al Qaeda-style Sunni Islamist group that has been active in Benghazi, a Libyan security official said.

Witnesses said the mob also included tribesmen, militia and other gunmen.

Yesterday, the sprawling, leafy compound in Benghazi stood empty as a spokesman for Libya's Supreme Security Committee said security forces came under heavy fire and were not prepared for the intensity of the attack.

Mr Stevens grew up in California, graduated from Berkeley and worked in North Africa as a Peace Corps volunteer.

He taught English in Morocco before joining the foreign service where he worked in the Middle East and North Africa.