(CNN) -- Mansour Daou is known as the "Black Box" of Moammar Gadhafi's regime -- like an aircraft's data recorder, he knows some of Libya's darkest secrets.
And as one of Gadhafi's top security officials, who remained at his side until the final hours, Daou has a unique insight into the astonishing downfall of Africa's longest-serving leader.
Now in an interview with CNN he describes how the dictator, who was once of the world's most feared leaders, was forced to scavenge for food and hide in abandoned houses in the coastal city of Sirte.
"He was very worried and erratic -- this could be because he was afraid," Daou said.
According to Daou, Gadhafi became desperate to travel to his birthplace, the village of Jaref, 20 kilometers west of Sirte, a journey that Daou feared was "suicide."
"He wanted to go to his village, maybe he wanted to die there or spend his last moments there," he said.
Finally, after NATO jets attacked his convoy, Gadhafi tried to escape on foot through drainage pipes, but was caught. He was later killed in circumstances that are still far from clear.
Daou spoke as he awaited trial at a detention facility in the city of Misrata, which bore the brunt of the regime's most brutal assault during the conflict. The most significant charges he faces relate to his alleged role in the Abu Salim prison massacre in 1996, and his role in the alleged hiring of African mercenaries by the regime during the conflict. He told CNN he had no role in those events.
The interview was initially delayed by a few hours -- officials said Daou was being interrogated and asked CNN to return in the evening to speak to him.
The CNN crew was taken to the bottom floor of the building and led into a conference room where Daou sat at a long table with his interrogator -- a tall, tough-looking Libyan man.
Daou, in his late 50s, wore a traditional Arabic gray dishdasha robe and seemed to be in good health.
During the hour-long interview, Daou described how he had been in the same car as Gadhafi as they made their chaotic escape from the former leader's hometown of Sirte.
Gadhafi left Tripoli for Sirte on August 18, according to Daou -- just two days before fighters seeking to oust him entered the capital.
Daou said he remained in Tripoli until it became clear the city was no longer safe for the regime's top tier.
He then fled to the city of Bani Walid on August 22, along with Gadhafi's son, Saif al-Islam and intelligence chief Abdullah al-Senussi. He stayed with them for four days before joining the former dictator in Sirte.
Daou said their living conditions went from bad to worse as the rebels tightened their siege of the city. They moved around abandoned houses every three to four days, he said, surviving on the little food they could find. Towards the end, they had no power, water or communication with the outside world. "Our lives had turned by about 180 degrees."
Gadhafi spent his final days writing and reading books he had stacked in suitcases, Daou said, but his behavior became more unpredictable. As fighters surrounded Sirte, Gadhafi's group wanted to leave the city.
Daou said he and others knew that if they did not leave before the siege there would be no way out. But Gadhafi refused to leave -- until October 20 -- when he and his son Mutassem decided to make the move to the former dictator's birthplace.
Their group of about 350 men had dropped to fewer than 200, according to Daou. "It started dropping daily with some killed, others wounded and those who had left with their families," he said.
Daou described their force as a mostly undisciplined civilian one under the command of Mutassem. They had no plan -- not for fleeing and certainly not for fighting.
Their convoy of more than 40 vehicles was supposed to head out before dawn when they thought anti-Gadhafi forces would be resting -- but they were too late.
At about 8 a.m. they set out to Gadhafi's birthplace but NATO jets quickly struck one of the vehicles in the convoy. The impact of the explosion triggered the airbags in the car and Gadhafi sustained a slight injury to his head or chest. Daou remembered a scene of chaos, confusion and horror.
As they tried to escape he says anti-Gadhafi fighters opened fire on their cars as they attempted to flee. Then a second airstrike by NATO followed.
"That is when we had the most casualties and destroyed vehicles, our car was hit after we got out of it. Here were many injured: someone lost an arm, another a leg, some were dead. It was terrifying," Daou recalled.
They had no option but to run; their escape on foot ended with heavy fire from fighters who surrounded them by the drainage pipes they were using to escape through.
Daou said he lost consciousness after he was hit by shrapnel in his back and does not know how Gadhafi died.
The death of Gadhafi ended the possibility of an insurgency that his loyalists could have mounted, he believes. "The regime and any power it may have had died with Gadhafi," he said.
The legacy of Libya's former dictator is now being debated. "It will be up to the historians, everyone has their opinion, some see him as a dictator who killed his own people, and there is an opposite view. History is usually written by the more powerful," he said.
Gadhafi believed he could remain in power, Daou said, adding that he and other members of the inner circle tried to convince the former strongman to leave the country since March "to leave with respect ... to save face." His sons rejected the idea, especially Saif: "It is not easy for someone who had been in power for 42 years, to believe that it is over in a minute," Daou said.
Daou said he had no idea where the former regime's most wanted men -- Saif and al-Senussi -- were. But with the International Criminal Court pursuing them, he believes they are probably still in Libya as no country will take them.
When asked if he thought Saif, who during the conflict vowed to fight until the end, was a fighter, Daou laughed quietly and said: "I don't know -- I don't think so."
As unrest broke out in the region in January, officials in Libya were worried, Daou recalled. "There was fear and there was concern that this wave could reach Libya and the feeling was right," he said.
Daou said he was in a car with Gadhafi and al-Senussi driving back to Tripoli from Sabha in the south when news reached them about the ousting of the president of neighboring Tunisia.
He said they had a serious discussion, but the threat was not taken seriously. According to Daou, Gadhafi felt betrayed by world leaders he considered allies.
"He spoke of friends he said let him down, and did not stand by him, like (Italian Prime Minister Silvio) Berlusconi, (former British prime minister) Tony Blair, the French president (Nicolas Sarkozy) and (Turkish Prime Minister Recep Tayyip) Erdogan," Daou said.
But a bigger betrayal came from within. Daou says there was a defense plan in place for the capital, but it was treason among the ranks of those who were tasked with securing Tripoli that led to the fall of the capital in a few days.
He said more than 3,800 troops were supposed to guard Tripoli's gates, but on the night anti-Gadhafi fighters entered the capital, fewer than 200 troops were on duty.
"There was big betrayal by the general who was in charge -- it was his brigade that was in charge. Tanks and military vehicles had no crews, watch towers were abandoned, security forces withdrew from the streets because this brigade was not present," Daou said.
With the regime he served for decades now history, Daou awaits trial by Libya's new rulers.
He told us in the presence of his interrogators he is being treated well -- but has yet to see a lawyer whom he has requested.
Daou has not visited Tripoli since August. He has no TV and does not know what it looks like now, with his former regime's green flags replaced by the new national flags and walls covered with anti-Gadhafi graffiti.
He says the revolution was the people's will and they won -- now he says they have to preserve it -- and Libya's unity.
Asked if he regretted being part of the regime, he sighed and chuckled. "Sometimes I regret everything, I have even regretted being alive, of course a person has regrets at a time in his life and looks back but unfortunately you sometimes regret when it is too late."
CNN's Raja Razek contributed to this report.