British Foreign Secretary William Hague welcomed Zeidan's release. "We will work with Libyan government on ensuring the transition remains on track and insecurity is addressed," he tweeted.
Militias demand more autonomy
In the eastern part 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," he told CNN's 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
Armed militias have roamed the country largely unchecked since the 2011 ouster of Gadhafi.
"We are starting from scratch, and I think it will take time," said Abdelaziz, the foreign minister. "As long as we have a sustained support on the part of the international community, I think Libya will make it."
Rights groups have said security remains a principal concern in Libya.
"The main problem affecting both justice and security is that armed militias still maintain the upper hand," Human Rights Watch said in a report last month. "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."
In a statement issued Thursday, the rights group said it was "deeply troubled" by Zeidan's detention, which it described as a clear violation of Libyan law.
"The incident highlights the grave security conditions in Libya today. Hopefully it will refocus attention on the urgent need to strengthen both the country's security forces and its judicial systems," it said.
Recent attacks have added to the uncertainty in Libya.
Gangs of armed men have surrounded key ministries, including the Justice Ministry, 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.
Libyan intelligence services have warned that the country is becoming a 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.
On Saturday, U.S. forces swooped into Tripoli and seized a Libyan national indicted in the 1998 American Embassy bombings in East Africa.