Gunmen ended a nearly two-week siege of Libya's Foreign Ministry in the capital after reaching a deal with the government, its Supreme Security Committee said late on Saturday.
In the oil-rich east, meanwhile, hundreds of leaders agreed to join forces to defend their territory against similar armed attacks.
A commander of an SSE group stationed at the gates of the vacant Foreign Ministry said it had been handed over to a committee made up of members of parliament and leaders connected to the armed protests.
The SSE is a group of ex-rebel fighters under the Ministry of Interior, now better armed and more powerful than the police.
"The protesters had retreated because (some of) their demands were realised," he told Reuters.
Foreign Ministry officials were not immediately available to comment on the details of the deal.
Other media outlets quoted the justice minister as saying the Foreign Ministry and the Justice Ministry had been handed over to a government committee.
Armed groups surrounded the ministries in the capital late last month to press parliament to pass a law banning anyone who held a senior position under late strongman Muammar Gaddafi from the new administration.
Rights groups and diplomats criticized the measure, saying its terms were too sweeping and could cripple the government.
They also argued it was unfair because it made no exception for those who had spent decades in exile and had been instrumental in the toppling of Gaddafi nearly two years ago.
Parliament caved in and approved the legislation a week later, leading the armed groups - who say they are revolutionaries and not militia - to expand their list of demands, including the resignation of Prime Minister Ali Zeidan.
The growing tension between the groups and the government has alarmed federalists and other factions in the east, prompting their leaders to unite to defend their territory from a similar assault.
Representatives from these groups pledged on Saturday to revive the Cyrenaica Congress. Formed about a year ago to demand greater autonomy for the east, it sets out a manifesto for a federal Libya.
"We will not let Cyrenaica be ruled by the power of force," said Ahmed Zubair al-Senussi, a distant relative of King Idris, who was deposed in a military coup led by Gaddafi in 1969.
Senussi will remain the symbolic head of the congress.
In addition to selecting a head and combining military forces, the leaders moved to start a television channel for the region.
The eastern congress agreed to start work on June 1, when it will hold its first assembly in the city of Al Baida.
For about 10 years after Libya became an independent state in 1951, the country was run along federal lines with three regions. Power was devolved to Cyrenaica, to the southern province of Fezzan and to Tripolitania in the west.