TRIPOLI, Libya—For more than five months in a city locked down by forces loyal to Col. Moammar Gadhafi, regime opponents in Tripoli's Fashloom neighborhood relied on a fellow resistance leader who told them with uncanny accuracy how to evade security sweeps and tipped them off to impending raids against them.
On Thursday, as a rebel advance broke Col. Gadhafi's grip over his capital, the man identified himself to those beyond his underground cell: He is Mahmoud Ben Jumaa, a senior officer in Col. Gadhafi's personal security force.
In his double-agent role in the uprising, Mr. Ben Jumaa by day issued orders to arrest or tail suspected rebels. By night, the 54-year-old met secretly with those trying to overthrow his boss, who in turn were part of a city-wide opposition to the strongman.
Even as battles continued for pockets of Tripoli on Thursday, a clearer picture is emerging to explain how Libya's uprising succeeded with little widespread bloodshed in the capital. In part, it is because onetime regime stalwarts—including internal security commanders as senior as Mr. Ben Jumaa—were secretly part of the rebel leadership.
"I directed one of the great oppressive organs of Gadhafi's government," Mr. Ben Jumaa said Thursday. "And all the while I was doing everything I could to make sure this revolution succeeded."
Mr. Ben Jumaa's account of his role, which began in February and eventually led him to evacuate his family from Tripoli, is corroborated by accounts of neighbors and two senior police officers in Fashloom.
In contrast with the revolution in neighboring Egypt, which was led by youthful revolutionaries, government and business leaders like Mr. Ben Jumaa played an apparently pivotal role in the Libyan uprising. Their apparent buy-in and leadership suggests that Libya's transition to a post-Gadhafi democracy may prove smoother than Iraq's efforts to reestablish order in the wake of the 2003 U.S.-led invasion that was broadly opposed by the country's ruling Baathists.
Of course, fighting remains fierce in Libya and the involvement of these people hardly guarantees a smooth transition. The collapse of Col. Gadhafi's rule has left a substantial leadership vacuum in the capital. The leaders who will now begin to fill the gaps will have to overcome the regional, tribal and ideological differences that have long divided Libya.
A Tripoli citizen mans a local security checkpoint as part of an initiative overseen by rebel-led neighborhood councils.
Mr. Ben Jumaa's local council forms the base level of the rebel governing structure that has sprung up in most of the country during the past six months. It is among some 20 neighborhood councils in Tripoli that answer to the Tripoli Council, which has steered the city's uprising and that answers, in turn, to the rebels' national governing body, the National Transitional Council.
Some 30 members of the Tripoli-wide council met Thursday and for the first time agreed to break their operational security, meeting as a group in a downtown hotel. The cadre of mostly middle-age professionals, including engineers, hotel managers and accountants, had been meeting in secret locations for months, using aliases to protect themselves from arrest or infiltration. Few knew each other by name or occupation.
On Thursday, they hugged and wept as they saw each other in the open, and introduced themselves by their real names.
The tight cell structure that Mr. Ben Jumaa helped organize in Fashloom, these people say, was replicated in other Tripoli neighborhoods. In the industrial suburb of Tajoura, local commanders organized patrols to alert residents to nightly raids by irregular militias loyal to Col. Gadhafi.
Patrol volunteers would communicate down alleyways and narrow lanes via coded signals that they would flash from the lights of their mobile-phone screens.
In Fashloom, police commanders' role in the rebel leadership is expected to expedite local police forces' return to the streets. Local leaders here say they have also handpicked many of the men who are now providing security in neighborhoods. That could help ease the challenge of disarming those groups and collecting the vast stockpiles of weapons that have circulated among Libyans in recent months.
When demonstrations broke out in February, Tripoli residents were quick to march. Col. Gadhafi's crackdown was harsh. Security forces opened fire on street demonstrators. Tripoli's huge size kept rallies localized and prevented organizers from achieving a critical mass of demonstrators.
By early March, Col. Gadhafi had switched off the Internet. Activists knew his intelligence forces monitored phones. Organizers began meeting around kitchen tables and in family rooms.
"The ground rule is that everyone came with an alias," said Jamal Derwish Boulsayn, a middle-age businessman who regularly hosted meetings of about 30 people at his home in Souq al-Jouma'a, a neighborhood near Fashloom. "That way if someone was a spy, or someone was grabbed, they couldn't tell security who the rest of us were."
Mr. Ben Jumaa—a 20-year veteran of Libya's Internal Security who rose to become the head of the office dedicated to Col. Gadhafi's personal security—linked up with Fashloom's rebel leaders from the start of demonstrations there. He and 12 others on the shadow neighborhood council oversaw antiregime activities.
Mr. Ben Jumaa's neighbors say they long suspected his loyalty wasn't absolute. They said he would tell neighbors how to deal with security services should they fall under suspicion, or how to keep clear of the web of spy networks that bolstered Col. Gadhafi over four decades of power.
"We all knew he was always unenthusiastic about what was happening in this country," said Abdel Basat al-Tubal, a member of the neighborhood committee who is also a brigadier general in the local police force.
Local rebel leaders calculated that Mr. Ben Jumaa's intimate knowledge of the security services' methods would help them dodge the regime's security forces, Mr. Basat al-Tubal said.
Mr. Ben Jumaa says he was in daily contact with security commanders closest to Col. Gadhafi. He said he would sort daily through intelligence from phone taps, rebel surveillance and interrogations, and pass on arrest orders for suspected rebels.
Mr. Ben Jumaa tipped off rebel leaders before several raids in Fashloom, giving dissidents a narrow window to hide their rebel contraband or seek out havens before the house raids began, several neighborhood activists said.
In nearby Souq al-Jouma'a, resistance-cell leader Hakim Boulsayn said he evaded arrest more than one time while he was visiting the district's clandestine armory, due to an informer high up in the internal security service. "Men like [Mr. Ben Jumaa] were working with many neighborhoods," he said.
At the beginning of August, Mr. Ben Jumaa received a call. A friend working in another branch of the security forces, he said, had spotted Mr. Ben Jumaa's name on an arrest list.
That night, Mr. Ben Jumaa and his family fled their apartment at 11 p.m. for a safe house. At 4 a.m., a force of eight Gadhafi security force vehicles surrounded his apartment building and busted through his door, said Abdel Hamid Sherif, a neighbor who said he watched the raid through his peephole.
Mr. Ben Jumaa says he ferried his family to Tunisia but stayed in hiding in Libya until Aug. 20, when the new wave of revolt erupted in Tripoli.
He emerged from his safe house as crowds of men from the Souq al-Jouma'a neighborhood stormed the streets. Feeling momentum turning against the regime, he went back to Fashloom the next day and spent the weekend organizing his neighborhood as Tripoli fell into rebel hands.