The attack began after protesters began massing outside the consulate
A small group of militants opened fire on the complex and gained entry
The militants set fire to the main building with the U.S. ambassador still inside
Control was regained more than four hours later
(CNN) -- Outside the U.S. consulate in Benghazi, Libya, on Tuesday night, protesters began massing.
The subject of their ire: a film mocking Islam's prophet.
But the demonstration organized by the radical Islamist group Ansar Al-Sharia soon turned violent, when a group of heavily armed militants "infiltrated the march to start chaos," said Libyan Deputy Interior Minister Wanis al-Sharif.
After four hours, the consulate was destroyed, its walls blackened by shooting flames. Four Americans, including U.S. Ambassador to Libya Chris Stevens, were dead.
U.S. officials were still trying Wednesday to piece together the details of how the attack unfolded.
Initial reports indicate the attack began around 10 p.m. as gunmen opened fire on the main compound of the U.S. consulate complex.
"According to our sources, the attack was the work of roughly 20 militants, prepared for a military assault," said Noman Benotman, once a leading member of the Libyan Islamic Fighting Group and now based at the Quilliam Foundation in London.
Within 15 minutes, the gunmen were able to enter the building and set it ablaze. Three people were inside when the fire broke out: Stevens, Foreign Service information management officer Sean Smith and a U.S. regional security officer -- all of whom had taken refuge in a safe room, according to senior State Department officials.
The three were forced to try to evacuate when the safe room became filled with smoke.
Photos of the compound taken Tuesday night show flames shooting from every orifice of the building as militants wielding weapons walk through the compound. Senior administration officials called the conditions inside "awful," describing "incredibly thick smoke and fire."
That heavy, black smoke added to the confusion of the situation and the three diplomatic officers became separated, the administration officials said.
Meanwhile, American and Libyan security personnel, forced to fend off an attack on the outside and the raging fire within, were grappling with how to handle the increasingly complicated scene, U.S. officials said.
The regional security officer with Stevens and Smith managed to escape the building and returned with others to try to rescue the men. For Smith, the rescue came too late. He had already succumbed to smoke inhalation by the time they arrived. Stevens, in Benghazi on a short trip from the capital Tripoli, was missing, apparently able to make his way out unnoticed in the chaos.
Just over a half hour after the first gunshots rang out, security personnel attempted to retake the main compound, but were repelled by heavy gunfire and retreated to an annex in the complex.
They made a second attempt at 11:20 p.m. -- more than an hour after the attack began -- and successfully regained control of the main building.
But the incident was far from over. The gunbattle continued and the attack moved from the main compound to the complex's annex.
"It was during that time that two additional U.S. personnel were killed and two others were wounded," one of the senior administration officials said.
Finally, at 2:30 a.m., four and a half hours into the attack, U.S. security personnel, assisted by Libyan forces, took back control of the entire consulate complex.
Still unknown at that time, however, was Stevens' whereabouts.
Libyans said bystanders had helped carry an unconscious Stevens to a hospital. However, U.S. officials could not confirm that account.
"We are not clear on the circumstances between the time he got separated from the rest of the group inside the burning building to the time we were notified that he was in a Benghazi hospital," the senior administration official said. "We were not able to see him until his body was returned to us at the airport."
Also unclear Wednesday was the significance of the timing of the attack, which fell on the 11th anniversary of the September 11 attacks on New York and Washington and coincided with a violent protest at the U.S. Embassy in Cairo, Egypt.
State Department officials said the two incidents at the diplomatic missions were not related and said they believe the Benghazi violence was a "clearly planned attack."
"It was not an innocent mob," one senior official said. "The video or 9/11 made a handy excuse and could be fortuitous from their perspective but this was a clearly planned military-type attack."
U.S. President Barack Obama, however, said it was too early to say whether the attack was pre-planned.
As dawn broke Wednesday, the magnitude of the previous night's events were felt by both Americans and Libyans. Charred debris and ash littered the floor of the burned-out consulate. A small American flag lay amid the rubble. And both the governments of the United States and Libya, on this "very, very difficult day," mourned the loss of Stevens, who had helped save Benghazi during last year's revolution.
"He risked his life to stop a tyrant, then gave his life trying to help build a better Libya," U.S. Secretary of State Hillary Clinton said.