TRIPOLI, Libya -- Libyan Prime Minister Ali Zidan was freed from captivity just hours after gunmen abducted him Thursday at dawn from the hotel where he resides in the capital, Tripoli, according to the state news agency.

The brazen abduction -- apparently in retaliation for the U.S. special forces' raid over the weekend that seized a Libyan al-Qaida suspect from the streets of Tripoli -- reflected the deep chaos and lawlessness gripping Libya.

Government Spokesman Mohammed Kaabar told the LANA new agency that Zidan has been "set free" and was on his way to his office. The brief report gave no further information and details were sketchy, but it appeared Libyan forces had intervened in some way and that the abductors did not free Zidan voluntarily.

A militia commander affiliated with the Interior Ministry told a private Libyan television station that the prime minister was freed when members of a Tripoli-based militia stormed the house where he was held hostage.

Haitham al-Tajouri, commander of the so-called "Reinforcement Force," told Al-Ahrar television that his men exchanged fire with the captors but that Zidan was not hurt.

"He is now safe in a safe place," he said. His account could not be independently verified.

Zidan's abduction reflected the weakness of Libya's government, which is virtually held hostage by powerful militias, many of which are made up of Islamic militants. Militants were angered by the U.S. capture of the suspected militant, known as Abu Anas al-Libi, and accused the government of colluding in or allowing the raid.

In a sign of Libya's chaos, Zidan's seizure was depicted by various sources as either an "arrest" or an abduction -- reflecting how interwoven militias are in Libya's fragmented power structure.

With the country's police and army in disarray, many are enlisted to serve in state security agencies, though their loyalty is more to their own commanders than to government officials and they have often intimidated or threatened officials. The militias are rooted in the brigades that fought in the uprising that toppled autocrat Moammar Gadhafi in 2011, and are often referred to as "revolutionaries."

On Tuesday, Zidan said the Libyan government had requested that Washington allow al-Libi's family to establish contact with him. Zidan insisted that Libyan citizens should be tried in their homeland if they are accused of crimes, stressing that "Libya does not surrender its sons."

Al-Libi is alleged to be a senior al-Qaida member and is wanted by the United States in connection to the bombing of American embassies in Tanzania and Kenya in 1998, with a $5 million bounty on his head.

Immediately after the raid, the Libyan government issued a statement saying it was carried out without its knowledge and asking Washington for "clarifications" about the operation.

"The U.S. was very helpful to Libya during the revolution and the relations should not be affected by an incident, even if it is a serious one," Zidan told a news conference in Tripoli.

In Brunei, U.N. Secretary-General Bank Ki-moon condemned the abduction and called it a "clear wake-up call" for countries undergoing democratic transitions.

"It would be very important for the Libyan government and its leadership to ensure inclusive dialogue and rehabilitation so that all the people can join the process," Ban said during an Asian summit.

The White House said it was still trying to get details Thursday morning about the incident and was in touch with senior U.S. and Libyan officials on the ground. The U.S. Embassy staff in Tripoli were all safe, it said.