Gunmen seized Libyan Prime Minister Ali Zeidan and held him for several hours before he was freed.
The premier appeared in good health when he arrived at government headquarters after his ordeal at the hands of former rebel militiamen, waving to waiting well-wishers as he climbed out of an armoured personnel carrier, AFP reports.
The pre-dawn seizure of Zeidan came five days after US commandos embarrassed and angered Libya's government by capturing senior Al-Qaeda suspect Abu Anas al-Libi off the streets of Tripoli and whisking him away to a warship.
Foreign Minister Mohammed Abdelaziz said Mr Zeidan had been freed a number of hours after being seized before dawn at his Tripoli hotel.
Moments before news broke of his release, Deputy Prime Minister Al-Seddik Abdelkarim had vowed that the government would not give in to the demands of the perpetrators of a "criminal act".
Mr Zeidan went straight into a meeting with his ministers and members of the General National Congress (GNC) - Libya's highest political authority.
Ministers had already met in his absence earlier in the day for an emergency session convened after his abduction.
A government statement said Zeidan had been taken "to an unknown destination for unknown reasons by a group" of men believed to be former rebels.
The Operations Cell of Libyan Revolutionaries, comprising former rebels and which had roundly denounced Libi's abduction and blamed Zeidan's government for it, said it had "arrested" Zeidan under orders from the public prosecutor.
But the cabinet said on its Facebook page that ministers were "unaware of immunity being lifted or of any arrest warrant" for the premier.
Later, another group of ex-rebels, the Brigade for the Fight against Crime, said it was holding Zeidan, according to the official LANA news agency.
The government said it suspected both the Operations Cell of Libyan Revolutionaries and the Brigade for the Fight against Crime of being behind Zeidan's abduction.
The two groups loosely fall under the control of the defence and interior ministries but largely operate autonomously.
Two years after the revolution that toppled Muammar Gaddafi, Libya's new authorities are struggling to rein in tribal militias and groups of former rebels.