Ali Zeidan Libya PM freed
Libya's Prime Minister Ali Zeidan addresses a news conference after his release (Reuters)

Libyan Prime Minister Ali Zeidan has returned to his office hours after being abducted by gunmen from his Tripoli hotel.

A broadcast by state television network Libyan TV showed Zeidan stepping out of an armoured vehicle in front of the government compound amid tight security.

Later Zeidan spoke briefly at an emergency cabinet meeting.

"We hope this matter will be treated with wisdom and rationality, far from tension," he said. "There are many things that need dealing with."

Zeidan thanked those who freed him, hinting a security operation took place, although circumstances of his release remain unclear.

"I salute the revolutionaries who had an important role. The real revolutionaries, those who rose above greedy demands, I salute them for what they did in this affair," Zeidan said.

Zeidan was taken by gunmen in a dawn raid at the luxury Corinthian Hotel where he resided in the Libyan capital.

Witnesses said that up to 150 gunmen drove up in pickup trucks and laid siege to the hotel before daylight. They broke into the hotel and some headed to the 21st floor where the prime minister was staying.

The gunmen scuffled with the prime minister's guards before seizing him and leading him out. Zeidan reportedly offered no resistance.

A militia group claimed responsibility for the abduction, saying the move was in retaliation for a US Special Forces raid that captured an al-Qaida suspect in Tripoli last week.

The group known as The Libyan Revolutionary Operations Chamber said it "arrested" Zeidan for allowing US troops to seize Nazih Abdul-Hamed al-Ruqai, known by his alias Anas al-Libi, the suspected mastermind behind the 1998 bombings at the American embassies in Kenya and Tanzania.

The group said it acted on the instructions of the public prosecutor but Justice Minister Salah al-Marghani denied the claim.

The Libyan Revolutionary Operations Chamber, a former rebel group that fought to topple Muammar Gaddafi, has loose links with the Interior Ministry. It had been tasked with providing security in the capital as part of a programme to reinsert armed rebel groups into the state apparatus.

It later emerged a second armed group might have been involved.

Libya's state news agency LANA reported that Zeidan had been kidnapped by the so called Anti-Crime Department, a militia set up by Nouri Boushameen, president of the National Congress, or parliament.

Boushameen called a news conference to distance himself from the kidnapping but said he visited the prime minister while in captivity and promised to resolve the crisis.

To add to the confusion, as Zeidan's whereabouts were unknown, an official with the Interior Ministry's anti-crime department told Reuters he was being held at the department and was in good health.

A few hours later government spokesman Mohammed Kaabar told LANA that Zeidan had been "set free", without providing further details.

Another militia commander also affiliated with the Interior Ministry told a private Libyan television station that the PM had been rescued by another militia group that stormed the house where he was held hostage.

Libya has been in turmoil ever since the removal of Muammar Gaddafi from power two years ago and the fragile central government has been struggling to rule a country fragmented by conflicting tribal loyalties.

Militia groups, including Islamist cells, are rife and control entire areas of the country.

"The abduction is like the shock that awakened Libyans. Facts on the ground now are clearer than never before: Libya is ruled by militias," said rights activist Hassan al-Amin.