TRIPOLI, Libya — Abdel Hakim Belhaj had a wry smile about the oddity of his situation.

Yes, he said, he was detained by Malaysian officials in 2004 on arrival at the Kuala Lumpur airport, where he was subjected to extraordinary rendition on behalf of the United States, and sent to Thailand. His pregnant wife, traveling with him, was taken away, and his child would be 6 before he saw him.

In Bangkok, Mr. Belhaj said, he was tortured for a few days by two people he said were C.I.A. agents, and then, worse, they repatriated him to Libya, where he was thrown into solitary confinement for six years, three of them without a shower, one without a glimpse of the sun.

Now this man is in charge of the military committee responsible for keeping order in Tripoli, and, he says, is a grateful ally of the United States and NATO.

And while Mr. Belhaj concedes that he was the emir of the Libyan Islamic Fighting Group, which was deemed by the United States to be a terrorist group allied with Al Qaeda, he says he has no Islamic agenda. He says he will disband the fighters under his command, merging them into the formal military or police, once the Libyan revolution is over.