(CNN) -- U.S. President Barack Obama on Wednesday strongly condemned the killing of the United States ambassador to Libya, J. Christopher Stevens, in a rocket attack on the U.S. Consulate in the city of Benghazi on Tuesday.
He called the attack "outrageous," and confirmed that four Americans, including Stevens, were killed.
"Chris was a courageous and exemplary representative of the United States," Obama said.
Stevens was the first U.S. ambassador to be killed in an attack since 1979
Libya's Prime Minister Abdurrahim el-Keib apologized "to the American people and the government, and also to the rest of the world" for the "cowardly criminal act."
U.S. Secretary of State Hillary Clinton identified a second victim as Sean Smith, a Foreign Service information management officer who was a ten-year veteran of the State Department, a husband and a father of two.
The two other victims have not been named.
An "angry crowd" marched on the consulate on Tuesday, furious about an online film considered offensive to Islam, Libya's Deputy Interior Minister Wanis al-Sharif said Wednesday. The U.S. mission in Egypt was also attacked Tuesday in response to the film.
Al-Sharif said that consulate security staff opened fire when they heard gunfire outside the mission.
"This led to more anger and this is when the consulate was stormed," he said, suggesting that there were elements loyal to the regime of deposed dictator Moammar Gadhafi aiming to create chaos among the protesters.
"Criminals managed to get in and they burned and ransacked the consulate," he said.
The U.S. mission is very badly damaged and was being looted on Wednesday, said a contractor working at the mission, who asked not to be named for security reasons.
He said he saw the bodies of all four Americans on the street Wednesday morning.
Libyan Deputy Prime Minister Mustafa Abushagur said Stevens was "a friend of Libya, and we are shocked at the the attacks on the U.S. consulate in Benghazi."
"I condemn these barbaric acts in the strongest possible terms. This is an attack on America, Libya and free people everywhere," Abushagur said on Twitter.
The contractor in Benghazi said he could hear rocket-propelled grenade attacks Tuesday night.
Libyans were also killed, the contractor said, saying the victims were shot on the spot.
The bodies of the four Americans are now at Benghazi airport, the contractor said, citing the Libyan minister of foreign affairs and a top immigration official in Benghazi.
Libya's governing party condemned the attack as a "criminal and cowardly act" and vowed to "track down the perpetrators and to maintain the country's security and the safety and security of its guests," Libya's official LANA news agency reported.
Stevens was the American envoy to the Libyan rebel movement that overthrew Gadhafi last year, based in the rebel capital of Benghazi.
Friends say he loved Libya and had a deep affinity for the Libyan people, enjoying heading out into the field and getting to know people.
A speaker of Arabic and French, he was among the first American diplomats sent to Libya in 2007 when the United States resumed ties with the Gadhafi regime.
The last time an American ambassador was killed by terrorists was in 1979, when the envoy to Afghanistan, Adolph Dubs, was kidnapped and killed during an attempt to rescue him, according to State Department records.
Stevens is the sixth U.S. ambassador to die by violence in the line of service. Two others have been killed in plane crashes.