Violent crime and clashes between armed militants are running rife in Libya as the jubilation of last year's liberation fades, to be replaced by the harsh and unromantic reality of building a new state.

Although much less frequent than the celebratory shooting in the weeks after Muammar Gaddafi died in October, the sound of gunfire can still be heard at night in Tripoli, where security sector workers say theft, infighting and murder are on the rise.

Last week, two grenade attacks were reported in central Tripoli and gunfights occur on a near-daily basis.

The country is coming down off a victory high, a western diplomat in the capital told Reuters.

Not only are there clashes between rival militias, but we are seeing a lot more reports of crime in the capital and I think it is because people are disillusioned with the slower-than-hoped progress of the country, the diplomat said.

The National Transition Council (NTC), Libya's internationally recognized but self-appointed government, has received praise for getting many of the country's ministries up and running and, notably, for drafting an election law in which NTC leaders will be unable to run in June elections.

But many Libyans thought progress would be faster, and the defence ministry and the interior ministry are failing to incorporate disparate militias, armed with anything from pistols to tanks, into a police force and an army.

These groups fought hard in the campaign to topple Gaddafi but now refuse to hand in their weapons, saying they are suspicious of the country's new rulers.

The ramshackle government lost control of a former Gaddafi stronghold Tuesday after local people staged an armed revolt, posing the gravest challenge yet to the NTC's authority.

The revolt in Bani Walid will heighten doubts in the West about the NTC government's ability to instil law and order crucial to rebuilding oil exports, to disarm tribal militias and to guard Libyan borders in a region where al Qaeda is active.

Elders in Bani Walid, 200 km (125 miles) southeast of the capital, said they were appointing their own local government and rejected any interference from the authorities in Tripoli.

Although seen unlikely to spread elsewhere, the fighting added to the problems besetting the fragile new government.

The sense of lawlessness - and the lingering influence of Gaddafi even in death - is exemplified in recent clashes between the neighboring towns of Assabia and Gharyan, 50 miles south of Tripoli.

ESCALATING FIGHTING

Although accounts are conflicting, residents from both towns -- perched on the edge of the sandstone Western, or Nafusa, Mountains -- say that a knife fight broke out at a weekly market along a road that connects them.

The towns' respective militias rapidly amassed their troops, blocked off the main connecting road with walls of dirt to hide behind and started a three-day battle, in which shells, mortars and 9-foot-long GRAD rockets were fired.

Near the front line, a towering Catholic church can be seen at the peak of a nearby hill. During the Italian occupation in the early 20th century, fighters from Gharyan and Assabia fought together to decolonise Libya.

During the fighting, the military council of Gharyan swore that they were fighting the remnants of pro-Gaddafi forces still hiding in Assabia.

Assabia and us are brothers, but due to the presence of Gaddafi fighters we have a problem, Gharyan spokesman Ismail al-Ayeb told Reuters.

He said there are more than 1,000 pro-Gaddafi troops in Assabia -- a town of just over 50,000 people -- and showed Reuters documents which listed tens of thousands of weapons that the Gharyan military council claims are in Assabia.

TORTURE CLAIMS

In Assabia, a different story was being told, in which residents not involved in the fighting were kidnapped and tortured, one to death, by Gharyan fighters.

We are not Gaddafi supporters. Gharyan just want to legitimise their fight against us, said Ibrahim Mohammed, 23, who was covered head to toe in black and blue bruises which he says he got from beatings with metal chains in Gharyan.

I was on the road to the capital and I was stopped by Gharyan fighters. They asked me where I was from and when I said Assabia they forced me out the car with guns and took me to a military base, he told Reuters from his bed at the central hospital in Assabia, having been released in a cease-fire agreement brokered by the NTC.

I recognized them as being from the military council in Gharyan, he said in a coarse voice, adding that his ankles were crushed in metal workshop clamps and that his finger and toe were smacked with metal bars. Blood seeped from under his fingernails during the interview.

During my interrogations, I saw our main military commander in Gharyan lying on the floor in a pool of blood ... he was barely breathing and they had tied a metal pole to his arms and legs and were giving him electric shocks, Ibrahim said.

The body of this Assabia military commander, Ezzedine al-Ghool, was anonymously dropped at the Tripoli hospital where it was later collected by members of Assabia's city council, including Bashir al-Nwer, who says Gharyan fighters took the body to Tripoli to avoid escalating the conflict by returning the tortured body directly to Assabia.

We have come to get the doctor's report which proves he was tortured to death. Then we will take his body to Assabia. Three days after Ezzedine was killed, his wife gave birth to his son, Ali, and we want the son to see his first and last glimpse of his father, he told Reuters at the morgue in Tripoli.

Ezzedine spent two months in a Gaddafi prison during the war and is heralded as a hero of the revolution.

Reuters travelled in a convoy of dozens of cars which transported Ezzedine's body back to Assabia hospital where Ezzedine's wife was recovering from giving birth a day before. On arrival, the widow's wails echoed through the corridors and she kissed her dead husband's face and whispered prayers.

This is your son, she said, holding her newborn child, tightly wrapped in blankets to protect him from the thin, cold mountain air.

TRUTH AND RECONCILIATION

So far, the NTC has been efficient at mediating and ending these sort of flare-ups that are happening all over the country and undermining Libya's fragile stability.

The Gharyan-Assabia cease-fire was brokered quickly, and prime minister Abdel Rahim El-Keib and NTC head Mustafa Abdel Jalil personally visited both towns.

But the NTC has yet to prove it can prevent militia fighting and rising violent crime.

Libya is making a transition from war to peace and trying to deal with what happened, said the western diplomat who is involved in a movement to start a truth and reconciliation committee to document war crimes committed during the civil war.

After going through what Libya went through, any country would have problems and especially as people realise that the country will take time for laws to be enforced and adhered to.

(Editing by Sonya Hepinstall)