(CNN) -- Just hours after gunmen kidnapped Libyan Prime Minister Ali Zeidan from a luxury hotel under the cover of darkness, he was released unharmed, a government official said.
"He's in good shape, the prime minister, and going to his office," said Nouri Abusahmain, president of the Libyan General National Congress. "He's fine, he's in good spirits."
Gunmen captured Zeidan before dawn from the Corinthia Hotel in Tripoli and put him into a convoy of waiting cars, according to a hotel clerk who was not authorized to speak to the media.
The five-star hotel that Zeidan calls home is popular among government officials, some of whom reside there, including the justice minister.
The witness reported no gunfire during the incident, and said the gunmen were respectful and "caused no trouble."
Zeidan's office initially called the abduction a "rumor" on its official Facebook page, but later posted an update that it was "coerced by kidnappers to deny the report."
His spokesman told CNN that the prime minister was kidnapped.
But the Operations Room of Libya's Revolutionaries, the militia that took him, said it merely detained him over financial and administrative corruption charges.
However, the justice ministry said there was no arrest warrant for Zeidan, calling the move a kidnapping. Abusahmain said the government was not aware of the charges and the prime minister is prepared to answer any questions.
The militia works with the interior ministry -- a not-altogether uncommon practice in Libya, which has tried to rein in the many militia groups unsuccessfully. Instead, various ministries have teamed up with them for their own needs, including providing security services.
Militias have run rampant in the nation since the revolution that ousted Moammar Gadhafi two years ago.
In the east of the country, militias are demanding more autonomy from the central government, and have severely constrained Libya's oil output, which is central to its export revenue.
Last month, Zeidan said the nation is trying to rebuild after decades under Gadhafi's rule. He shot down reports that Libya is a failed state.
"We are trying to create a state, and we are not ashamed of that," Zeidan told CNN's Christiane Amanpour. "The outside world believes that Libya is failing, but Libya was destroyed by Gadhafi for 42 years, and was destroyed by a full year of civil war. And that's why we are trying to rebuild it."
Part of Libya's rebuilding involves reconciliation and accountability, Zeidan said last month. Libya has an interim president, but the prime minister holds all executive powers.
Security an issue
Rights groups have said security remains a main concern in Libya.
"The main problem affecting both justice and security is that armed militias still maintain the upper hand," Human Rights Watch said. "They have various agendas -- financial, territorial, political, religious -- and operate with impunity two years after the Gadhafi regime ended. Successive interim governments have failed to assert control over these militias, preferring to contract them as parallel forces to the army and police."
Ministries under attack
Recent attacks have added to the uncertainty.
Gangs of armed men have surrounded key ministries, including justice, trying to force out members of the democratically elected government.
Libyan Justice Minister Salah Marghani was forced to evacuate after armed militias surrounded his ministry in April.
The nation continues to struggle to rein in militia groups that menace the nation. Libyan intelligence services have said the country is becoming a safe haven for al Qaeda to regroup and regenerate itself.
Numerous weapons left over after Gadhafi's downfall are providing groups with different motivations to form their own militias, government officials said.
Days before the Thursday incident, U.S. forces swooped into Tripoli on Saturday and seized a Libyan national indicted in American embassy bombings in East Africa.
Abu Anas al Libi is a suspect in the 1998 embassy attacks in Kenya and Tanzania, and American officials have described him as "one of the world's most wanted terrorists."
The militia group said the prime minister's capture had nothing to do with the arrest of al Libi. However, three days ago, it issued a warning that whoever collaborated with "foreign intelligence services" in the arrest of the terror suspect will be punished.
It's unclear what role Zeidan played in the arrest of al Libi by U.S. forces.
But the Libyan government has decried the arrest of the terror suspect, and its national congress on Tuesday demanded that the United States hand him over.
U.K. Foreign Secretary William Hague welcomed the release of the prime minister.
"We will work with Libyan government on ensuring the transition remains on track and insecurity is addressed," he tweeted.
CNN's Victoria Eastwood and Jomana Karadsheh contributed to this report from Tripoli
™ & © 2013 Cable News Network, Inc., a Time Warner Company. All rights reserved.