The US ambassador in Libya and three other embassy staff were killed in a rocket attack after the diplomat’s car was targeted in the eastern city of Benghazi, it was confirmed on Wednesday.

A statement from President Obama “condemned the outrageous attack on our diplomatic facility in Benghazi, which took the lives of four Americans, including ambassador Chris Stevens”.

The president added: “Chris was a courageous and exemplary representative of the United States.”

Earlier, Libya’s interior ministry confirmed that Stevens died in the attack. “The American ambassador and three staff members were killed when gunmen fired rockets at them,” a Libyan official told Reuters.

An unconfirmed photograph posted on Facebook appears to show a mob dragging a lifeless Stevens along the ground, his shirt off. Some reports say he suffocated to death. Libya’s deputy prime minister, Mustafa Abushagur, said security forces had launched a manhunt to find the killers. “I condemn the cowardly act of attacking the US consulate and the killing of Mr Stevens,” he said.

The exact circumstances of the ambassador’s death remain unclear. On Tuesday night a group of extremists attacked the US consulate building in Benghazi, setting it on fire, and killing one US diplomatic officer.

On Tuesday the US state department confirmed that one of its employees had been killed by the mob that stormed the US mission in Benghazi, incensed by a US film that they deemed blasphemous to the prophet Muhammad. Libyan officials said Stevens and two security staff were in their car when gunmen fired rockets at it, Reuters reported. The official said the US military had sent a military plane to transport the bodies to Tripoli and to fly them back to the US.

One witness told the Guardian on Wednesday that a mob fired at least one rocket at the US consulate building in Benghazi and then stormed it, setting everything ablaze. “I was there about an hour ago. The place [consulate] is totally destroyed, the whole building is on fire,” said Mohammed El Kish, a former press officer with the National Transitional Council, which handed power to an elected parliament last month. He added: “They stole a lot of things.”

Kish, who is from Benghazi, blamed the attack on hardline jihadists. He said locals in Benghazi were upset by the activities of Islamist groups and would revolt against them. He also said the US consulate was not well protected, unlike the fortified US embassy in the capital, Tripoli. “It wasn’t that much heavily guarded. In Tripoli the embassy is heavily guarded.”

The ambassador’s killing follows an attack in June on the UK ambassador to Libya, Dominic Asquith. Two British bodyguards were injured after a rocket was fired at Asquith’s convoy in Benghazi, hitting his security escort. There have been similar attacks in Benghazi on the Red Cross and the UN. It is not clear why the US ambassador had returned to Benghazi at a time of security concerns.

On Wednesday the British embassy in Tripoli said that after the attack in June UK diplomats were pulled out of Benghazi. “Nobody is based there permanently. We have a villa there and an office, with staff travelling there from time to time,” it said. No British staff were injured during Tuesday’s attack on the US mission, it added.

Benghazi was the cradle of Libya’s revolution last year against Muammar Gaddafi. The rebels’ military victory was made possible by a Nato air campaign against regime targets, supported by the US. But in recent months radical Islamist groups have become increasingly active in much of the east of the country, threatening the country’s weak civilian government in Tripoli.

According to the Libya Herald, citing local witnesses, those who attacked the US mission included members of the hardline Islamist group Ansar Al-Sharia. It reported that Libyan security forces tried to defend the embassy building but withdrew under heavy fire. The attackers opened fire on the buildings and threw homemade bombs into the compound, setting off small explosions. Fires burned around the compound.

The assault followed a protest in neighbouring Egypt where demonstrates scaled the walls of the US embassy, tore down the US flag, and burned it during a protest over the same film which they said insulted the prophet Muhammad.

Speaking on Tuesday â€“ before the death of the US ambassador was reported â€“ the US secretary of state, Hillary Clinton, said she was heartbroken at the death of a US officer in Benghazi. “I condemn in the strongest terms the attack on our mission in Benghazi today,” Clinton said in a statement. “We have confirmed that one of our State Department officers was killed.Â We are heartbroken by this terrible loss. Our thoughts and prayers are with his family and those who have suffered in this attack.”

She said she had been in contact with Mohamed Magarief, the new president of Libya’s General National Congress, which was formed following post-Gaddafi elections in June. Clinton asked him “to co-ordinate additional support to protect Americans in Libya. President Magarief expressed his condemnation and condolences and pledged his government’s full co-operation”.

She said that “some have sought to justify this vicious behaviour as a response to inflammatory material posted on the internet. The United States deplores any intentional effort to denigrate the religious beliefs of others. Our commitment to religious tolerance goes back to the very beginning of our nation. But let me be clear: there is never any justification for violent acts of this kind.”

The UK foreign secretary, William Hague, condemned the attack on Wednesday. “There is no justification for such an attack and the appalling death of an US official. My thoughts and condolences are with his family and all his colleagues at the State Department,” he said.

“It is essential that the Libyan authorities take urgent action to improve security, particularly in Benghazi, and identify those responsible for such attacks.”

The attack on the consulate comes two weeks after Salafists used a bulldozer to destroy a key Sufi Islamic shrine in central Tripoli, watched by security forces who did not intervene. It is likely to be the first challenge for Libya’s new prime minister, due to be elected on Wednesday by the 200-member national parliament.