Libyan Prime Minister Ali Zeidan returned unharmed to government headquarters in Tripoli Thursday, soon after he was released by former rebels who had abducted and held him for several hours.
Gunmen seized Mr. Zeidan early Thursday at a Tripoli hotel where he lives.
A group known as the Operations Room of Libya's Revolutionaries claimed responsibility, saying they had "arrested" the prime minister.
The group had blamed Mr. Zeidan's government for playing a role in Saturday's U.S. Special Forces raid in Libya that nabbed senior al-Qaida operative Abu Anas al-Libi, who is now being held aboard a U.S. Navy ship.
U.N. Secretary-General Ban Ki-moon condemned the abduction of the Libyan prime minister. Mr. Ban said it was a "wake up call" for Libya and every other country experiencing political transformation.
The country has struggled with instability and violence since the ouster of longtime dictator Moammar Gadhafi in late 2011.
Rebel groups that fought against Mr. Gadhafi have given rise to militias and militant groups that control parts of the country.
Attacks have targeted foreign diplomatic missions in Libya, including the Russian embassy last week, the French embassy in April and a U.S. consulate last year.
Libya asked the United States to explain the operation against Abu Anas al-Libi, calling it a kidnapping. Mr. Zeidan said Tuesday his country wants to keep good relations with the United States, but that Libyan citizens should be judged at home.
U.S. Secretary of State John Kerry defended the capture of the al-Qaida operative, calling it "legal and appropriate." He said the Libyan government's complaints were unfounded, and that the suspect will go before a court of law.