WASHINGTON/BENGHAZI, Libya (Reuters) - President Barack Obama vowed on Wednesday to “bring to justice” the Islamist gunmen responsible for a ferocious assault that killed the U.S. ambassador to Libya and three other Americans - an attack that may have been organized in advance.

U.S. President Barack Obama speaks at a campaign rally in Las Vegas, Nevada September 12, 2012. REUTERS/Kevin Lamarque

Ambassador Christopher Stevens and the other Americans died after the gunmen attacked the lightly fortified U.S. consulate and a safe house refuge in Benghazi on Tuesday night. The attackers were part of a mob blaming America for a film they said insulted the Prophet Mohammad.

Obama said he had ordered an increase in security at U.S. diplomatic posts around the globe following the assault.

The U.S. consulate was overrun and torched in a military-style assault, the ambassador left lost and dying alone in the smoke while rescuers ran into a deadly ambush as they sought to save survivors. The attackers used guns, mortars and grenades. U.S. and Libyan officials said the attack may have been planned in advance.

The violence in the eastern city, a cradle of Libya’s U.S.-backed uprising against Muammar Gaddafi last year, came on the 11th anniversary of al Qaeda’s attacks on the United States on September 11, 2001. Another assault was mounted on the U.S. embassy in Cairo on Tuesday in which protesters, who included Islamists and teenage soccer fans, tore down and burned a U.S. flag.

In Cairo, security forces late on Wednesday fired tear gas to disperse more stone-throwing demonstrators near the embassy. Live TV showed hundreds of demonstrators at the U.S. embassy.

Stevens, a 52-year-old California-born diplomat who spent a career operating in perilous places, became the first American ambassador killed in an attack since Adolph Dubs, the U.S. envoy to Afghanistan, died in a 1979 kidnapping attempt.

A Libyan doctor pronounced him dead of smoke inhalation. U.S. information technology specialist Sean Smith and two other Americans who have not yet been identified also were killed.

Among the assailants, Libyans identified units of a heavily armed local Islamist group, Ansar al-Sharia, which sympathizes with al Qaeda and derides Libya’s U.S.-backed bid for democracy.

U.S. government officials said the Benghazi attack may have been planned in advance, also adding that there were indications that Ansar al-Sharia - which translates as Supporters of Islamic Law - may have been involved.

They said some reporting from the region suggested that members of al Qaeda’s north Africa-based affiliate, known as Al Qaeda in the Islamic Maghreb, may have been involved.

“It bears the hallmarks of an organized attack,” one U.S. official said. However, some U.S. officials cautioned against assuming that the attacks were deliberately organized to coincide with the September 11 anniversary.

Security personnel were separated from Stevens during the attack, U.S. officials said, describing a chaotic scene of smoke, gunfire and confusion.

A U.S. official said Washington had ordered the evacuation of all U.S. personnel from Benghazi to Tripoli and was reducing staffing in the capital to emergency levels.

The U.S. military is moving two Navy destroyers toward the Libyan coast, giving the Obama administration flexibility for any future action against Libyan targets, according to a U.S. official. The military also is dispatching a Marine Corps anti-terrorist security team to boost security in Libya.

‘SHOCKING ATTACK’

“The United States condemns in the strongest terms this outrageous and shocking attack,” Obama said, while insisting it would not threaten relations with Libya’s new government. “... And make no mistake, we will work with the Libyan government to bring to justice the killers who attacked our people.”

Libyan leader Mohammed Magarief apologized to the United States over an attack.

The violence in Benghazi and Cairo threatened to spread to other Muslim countries. Police fired teargas at angry demonstrators outside the U.S. embassy in Tunisia and several hundred people gathered in front of the U.S. embassy in Sudan. In Morocco, a few dozen protesters burned American flags and chanted slogans near the U.S. consulate in Casablanca.

The attacks could alter U.S. attitudes towards the wave of revolutions across the Arab world that toppled secularist authoritarian leaders in Egypt, Libya and Tunisia and brought Islamists to power.

The violence also could have an impact on the closely contested U.S. presidential race ahead of the November 6 election.

Republican Mitt Romney, Obama’s challenger, criticized the president’s response to the crisis. He said the timing of a statement from the U.S. embassy in Cairo denouncing “efforts by misguided individuals to hurt the religious feelings of Muslims” made Obama look weak as protesters were attacking U.S. missions.

Romney said it was “disgraceful” to be seen to be apologizing for American values of free speech. Obama’s campaign accused Romney of trying to score political points at a time of national tragedy. Obama said Romney has a tendency “to shoot first and aim later.”

Western countries denounced the Benghazi killings and Russia expressed deep concern, saying the episode underscored the need for global cooperation to fight “the evil of terrorism.”

The attack raised questions about the future U.S. diplomatic presence in Libya, relations between Washington and Tripoli, and the unstable security situation after Gaddafi’s overthrow.

Libyan Deputy Interior Minister Wanis al-Sharif said Stevens and another diplomat died as a result of the consulate attack, while the other Americans died in what a Libyan military officer called an intense and highly accurate mortar attack on the safe house.

Ziad Abu Zaid, the duty doctor in the emergency room at Benghazi Medical Centre on Tuesday, said he had treated Stevens.

“He came in a state of cardiac arrest. I performed CPR for 45 minutes, but he died of asphyxiation due to smoke inhalation.”

U.S. officials said Stevens, Smith and one security officer were trapped under fire in the burning consulate building.

The security officer made it outside and returned with help to search for the diplomats, officials said. The searchers found Smith, who was already dead, but were unable to find Stevens amid repeated exchanges of gunfire between Libyan security forces and the attackers over the next several hours.

“At some point in all of this ... we believe that Ambassador Stevens got out of the building and was taken to a hospital in Benghazi. We do not have any information on what his condition was at that time,” a senior U.S. official said.

Stevens’ body was later returned to U.S. custody at Benghazi airport, the official said. Images of Stevens, purportedly taken after he died, circulated on the Internet. One showed him being carried, with a white shirt pulled up and a cut on his forehead.

Two more Americans died when a squad of U.S. troops sent by helicopter from Tripoli to rescue the diplomats from the safe house came under mortar attack, said Captain Fathi al-Obeidi, commander of a Libyan special operations unit ordered to meet the Americans.

“It was supposed to be a secret place and we were surprised the armed groups knew about it,” Sharif said of the safe house.

Witnesses said the mob at the consulate included tribesmen, militia and other gunmen. Hamam, a 17-year-old who took part in the attack, said Ansar al-Sharia cars arrived at the start of the protest but left once fighting started.

“The protesters were running around the compound just looking for Americans, they just wanted to find an American so they could catch one,” he said.

‘WE STARTED SHOOTING AT THEM’

“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,” he said.

“There was some Libyan security for the embassy outside but when the hand-made bombs went off they ran off and left.”

Hamam said he saw an American die in front of him in the mayhem that ensued. He said the body was covered in ash.

Clips of the “Innocence of Muslims,” the film that stirred the deadly attacks, had been circulating on the Internet for weeks before protests erupted. They show an amateurish production portraying the Prophet Mohammad as a womanizer, a homosexual and a child abuser.

For many Muslims, any depiction of the Prophet is blasphemous and caricatures or other characterizations have in the past provoked protests all over the Muslim world.

U.S. media said the film was produced by an Israeli-American property developer. Internet links indicated it was by Sam Bacile, a name that could have Egyptian origins. But Reuters could not independently confirm his responsibility for the film, or even that Bacile was his real name.

Egypt’s Coptic Orthodox church issued a statement condemning some Copts - Egyptian Christians - living aboard who it said had financed “the production of a film insulting Prophet Mohammad,” while a U.S.-based Egyptian Christian who said he promoted the film said he was sorry that U.S. diplomats had been killed.

Morris Sadek, speaking to Reuters by phone from the United States, said his objective was to highlight discrimination against Christians who make up about 10 percent of Egypt’s 83 million people. He said Sam Bacile was the writer and director and described him as an “American.”

Many Muslim states focused their condemnation on the film and will be concerned about preventing a repeat of the fallout seen after publication in a Danish newspaper of cartoons of the Prophet Mohammad. This touched off riots in the Middle East, Africa and Asia in 2006 in which at least 50 people died.

Afghan President Hamid Karzai called the making of the movie a “devilish act” but said he was certain those involved in its production were a very small minority.

The U.S. embassy in Kabul appealed to Afghan leaders for help in “maintaining calm” and Afghanistan shut down the YouTube site so Afghans would not be able to see the film.

General Martin Dempsey, the chairman of the U.S. military’s Joint Chiefs of Staff, took the unusual step of telephoning a radical Florida Christian pastor, Terry Jones, and asking him to withdraw his support for the film. Earlier provocative acts by Jones, like publicly burning a Koran, had sparked Muslim unrest.

U.S. Secretary of State Hillary Clinton said the attack was the work of a “small and savage group.”

U.S. ambassadors in such volatile countries as Libya have tight security, usually travelling in well-protected convoys. Diplomatic missions are normally protected by Marines or other special forces.

Abdel-Monem Al-Hurr, spokesman for Libya’s Supreme Security Committee, said Libyan security forces came under heavy fire and “were not prepared for the intensity of the attack.”