Hundreds of Yemeni demonstrators broke through the main gate of the heavily fortified compound in eastern Sanaa, shouting "We sacrifice ourselves for you, Messenger of God". Earlier they smashed windows of security offices outside the embassy and burned cars.
"We can see a fire inside the compound and security forces are firing in the air. The demonstrators are fleeing and then charging back," one witness told Reuters. A security source said at least 15 people were wounded, some by bullets. An embassy spokesman said its personnel were reported to be safe.
In Egypt, protesters hurled stones at a police cordon around the U.S. embassy in central Cairo after climbing into the embassy and tearing down the American flag. The state news agency said 13 people were injured in violence which erupted on Wednesday night after protests on Tuesday.
A day earlier, Islamist gunmen staged a military-style assault on the U.S. consulate and a safe house refuge in Benghazi, eastern Libya. The U.S. ambassador Christopher Stevens and three other Americans died in the assault, carried out with guns, mortars and grenades. Eight Libyans were injured.
U.S. President Barack Obama vowed to "bring to justice" the Islamist gunmen responsible and the U.S. military moved two navy destroyers towards the Libyan coast, in what a U.S. official said was a move to give the administration flexibility for any future action against Libyan targets.
The military also dispatched a Marine Corps anti-terrorist security team to boost security in Libya, whose leader Muammar Gaddafi was ousted in a U.S.-backed uprising last year.
The attack, which U.S. officials said may have been planned in advance, came on the 11th anniversary of al Qaeda's attacks on the United States on September 11, 2001.
The attackers were part of a mob blaming America for a film they said insulted the Prophet Mohammad. Clips of the Innocence of Muslims, had been circulating on the Internet for weeks before the 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 characterisations have in the past provoked protests all over the Muslim world.
An actress in the California production said the video as it appeared bore no resemblence to the original filming. She had not been aware it was about the Prophet Mohammad.
Among the assailants, Libyans identified units of a heavily armed local Islamist group, Ansar al-Sharia, which sympathises with Al Qaeda and derides Libya's U.S.-backed bid for democracy.
U.S. officials said some reporting from the region suggested members of Al Qaeda's north-Africa based affiliate may have been involved.
Yemen, a key U.S. ally, is home to Al Qaeda in the Arabian Peninsula (AQAP), viewed by Washington as the most dangerous branch of the militant network established by Osama bin Laden.
Mr Obama said he had ordered an increase in security at U.S. diplomatic posts around the globe. Protests also erupted this week outside U.S. missions in Tunisia, Sudan and Morocco.
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, Mr Obama's challenger, criticised 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 Mr Obama look weak as protesters were attacking U.S. missions.
Mr Romney said it was "disgraceful" to be seen to be apologizing for American values of free speech. Mr Obama's campaign accused Romney of trying to score political points at a time of national tragedy. Obama said Romney had 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.
Mr 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 when a squad of U.S. troops sent by helicopter from Tripoli to rescue the diplomats from the safe house came under mortar attack.
"It was supposed to be a secret place and we were surprised the armed groups knew about it," Captain Fathi al-Obeidi, commander of a Libyan special operations unit ordered to meet the Americans, said of the safe house.
Witnesses said the crowd at the consulate included tribesmen, militia and other gunmen. Libyan leader Mohammed Magarief apologised to the United States over the attack.
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."