The Libya Revolutionaries Operations Room said it had captured Ali Zeidan in Tripoli, claiming it was acting on orders from the prosecutor general.
The justice ministry denied this.
The militia was one of several groups angered by a US commando raid on Libyan soil on Saturday in which senior al-Qaeda suspect Anas al-Liby was seized.
Many saw the raid as a breach of Libyan sovereignty. There is growing pressure on the government to explain if it was involved but in a statement, the Revolutionaries Operations Room (LROR) said its actions had not been related to Anas al-Liby’s detention.
The official Lana news agency also named another formal rebel group, the Brigade for the Fight against Crime, as being involved.
State TV broadcast live as Ali Zeidan arrived at his office in Tripoli. There was a high security presence as his car pulled up outside. The prime minister made no immediate comment but was expected to give a news briefing shortly.
Foreign Minister Mohammed Abdelaziz said earlier he had no details on the circumstances of the release.
It was unclear whether the militia had released the prime minister voluntarily or whether other security forces had intervened.
Ali Zeidan had been taken in a pre-dawn raid on the Corinthia Hotel by more than 100 armed men.
The LROR said it was acting on the orders of the prosecutor general and in accordance with a section of Libya’s criminal code relating to “crimes and misdemeanors harmful to state security”.
But Justice Minister Salah al-Marghani said the prosecutor general had issued no arrest warrant, according to state-run National Libyan TV.
Photographs circulating online and shown on TV showed Ali Zeidan surrounded by what it said were armed men as he was led away. There were no reports of violence during his capture.
The prime minister was reportedly being held at the interior ministry anti-crime department in Tripoli, where an official said he was being treated well.
In a news conference shortly before the release was announced, the government condemned the “criminal act” of his detention and said it would not give in to “blackmail”.
The LROR is one of a number of militias operating in Libya which are nominally attached to government ministries but often act independently and, correspondents say, often have the upper hand over police and army forces.
The government has been struggling to contain the militias, which were heavily involved in the revolt which overthrew Colonel Muammar Gaddafi and, two years on, still control many parts of the country.
Eac3NJ3Q6UgThe US House Ethics Committee has voted to release its report on former Republican Representative…
ABC News has agreed to pay $15 million to President-elect Donald Trump to settle a…
South Korea’s parliament has voted to impeach President Yoon Suk Yeol over his failed attempt…
Israeli war planes have carried out more than 100 air strikes in Syria on December…
President-elect Donald Trump has threatened to impose 100% tariffs on the BRICS countries if they…
Syrian troops have withdrawn from the city of Aleppo following an offensive by rebels opposed…