(CNN) -- Tuesday's attack on the U.S. Consulate in Benghazi, Libya, was planned in advance, and the attackers used the protest outside the consulate as a diversion, U.S. sources told CNN Wednesday. The sources could not say whether the attackers instigated the protest or merely took advantage of it. The sources do not believe Ambassador Chris Stevens was specifically targeted.
An Arabic speaker who loved Libya and understood it deeply, Stevens died along with three other Americans when an angry mob stormed the U.S. Consulate in Benghazi.
He was the first U.S. ambassador to be killed violently in the line of duty since 1979.
The consulate was one of several American diplomatic missions in the Middle East to face protests Tuesday after the release online of a film mocking Islam and depicting the Muslim prophet Mohammed as a child molester, womanizer and ruthless killer.
But a London think tank with strong ties to Libya speculated Wednesday that Stevens was actually the victim of a targeted al Qaeda revenge attack.
The attack "came to avenge the death of Abu Yaya al-Libi, al Qaeda's second in command killed a few months ago," the think tank Quilliam said Wednesday.
It was "the work of roughly 20 militants, prepared for a military assault," the think tank said, noting that rocket-propelled grenade launchers do not normally appear at peaceful protests, and that there were no other protests against the film elsewhere in Libya.
The planned attack came in two waves, one which prompted U.S. officials to leave the consulate for a secure location, and the second directed at the place of retreat, Quilliam said.
The think tank cited unnamed sources on the ground in Benghazi and abroad.
Obama strongly condemned the attack, which he called "outrageous."
"Chris was a courageous and exemplary representative of the United States," he said.
During last year's revolution against Gadhafi, Secretary of State Hillary Clinton dispatched him to be the American link with the rebels.
"He arrived on a cargo ship in the port of Benghazi and began building our relationships with Libya's revolutionaries," she said Wednesday. "He risked his life to stop a tyrant, then gave his life trying to build a better Libya."
She identified a second victim as Sean Smith, a Foreign Service information management officer who was a 10-year veteran of the State Department, a husband and a father of two.
The two other victims have not been named. Clinton said the government was working to contact their families.
Libyan 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."
About 50 U.S. Marines from a rapid reaction force headed to Libya after the attack, U.S. officials said Wednesday.
Libyan Deputy Interior Minister Wanis al-Sharif blamed the violence on people loyal to deposed dictator Gadhafi.
Consulate security staff opened fire after they heard gunfire outside the mission, al-Sharif said.
"This led to more anger, and this is when the consulate was stormed," he said. "Criminals managed to get in and they burned and ransacked the consulate."
The U.S. mission is very badly damaged and was being looted 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 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," he 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 were at Benghazi airport, the contractor said, citing the Libyan minister of foreign affairs and a top immigration official in Benghazi.
Friends say Stevens 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 U.S. diplomats sent to Libya in 2007 when the United States resumed ties with the Gadhafi regime.
The last time an American ambassador was murdered 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.
The United States was taking added security measures to protect its citizens worldwide after Tuesday's attacks.