The Libyan government has taken back control of its interior ministry from an armed group that had besieged the building for a week, a spokesman has told the AFP news agency.
The building in Tripoli, Libya's capital and largest city, was taken back on Wednesday.
The group had ordered staff to leave the ministry on July 2 and its men had remained there for days. They had closed off the compound's main entry with mounds of sand.
One of them had said they would stay until authorities broke up an armed force, known as the Supreme Security Committee (SSC), which says it is backed by the interior ministry.
The SSC is composed of militiamen, which are the former rebel fighters from the 2011 war that ousted Muammar Gaddafi.
"The government had formed a ministerial committee to solve the crisis and it succeeded in getting the ministry back last night," a ministry official, who declined to be named, told the Reuters news agency.
"We don't know what agreement was reached but right now workers are checking the building and it is in good condition."
State news agency LANA said the ministry was calling for workers to come back to the office.
Remnants of war
Armed groups made up of former rebel fighters from different parts of the North African country have grown in power and ambition since Gaddafi's ouster and the weak central government has struggled to impose its authority over them.
Fighting had erupted on June 8 this year after dozens of demonstrators stormed a base in the eastern city of Benghazi belonging to the Libya Shield brigade, a group of militias that is understood to be aligned with the Defence Ministry.
The protesters were demanding that militias leave their camp and submit to the full authority of Libya's security forces.
Libya's army chief of staff resigned after 31 people were killed in clashes, according to members of the national assembly.
Protesters gathered in Tripoli on July 7 to ask the government to remove arms and evacuate unofficial militia groups.
The government has said it is drawing up plans to disband militias but has not given details of how the authorities will tackle fighters.