Libya's government has won control of one of the last strongholds of Muammar Gaddafi's loyalists after fierce battles that left dozens dead and thousands displaced.
The capture of Bani Walid was a triumph for the rulers who replaced Gaddafi's regime, but the fact that it took a full year underlined the fractious nature of the country and the new regime's inability to impose its authority over squabbling tribes and heavily armed militias.
The victory could even spark new violence. The government-backed militia that led the charge came from the city of Misrata, a long-time rival of Bani Walid, and recriminations could result.
In the centre of Bani Walid, 90 miles from Tripoli, fighters fired their weapons into the air in celebration. Columns of smoke billowed into the sky near the airport outside, where clashes were still ongoing, despite official statements that the government was in full control.
Shops were closed and the town was deserted. A power station was destroyed, the main hospital was not functioning and a doctor was among the wounded. Fighters opened fire on signs that carried the old name of Libya under Gaddafi.
Mohammed al-Taib, a commander of a pro-government militia called Libya Shield, said that his forces control the town centre, but there were still some clashes going on.
Omar Boughdad, a commander from the Misrata militia, said his forces would remain in the town to keep Gaddafi loyalists out. "The loyalists have fled to the valleys, but we will clean up these places and we will not leave again," he said.
Bani Walid is one of the last major pockets of support for the former regime, and disarming its militants has been one of the most daunting tasks facing the government.
"Bani Walid is under full control," the official LANA news agency said.
LANA said that 13,000 families were displaced by the fighting. Families fled by car, and workers walked several miles to escape the gunfire.