By Ayman al-Warfalli and Feras Bosalum
BENGHAZI Libya (Reuters) - Libyan tanks rumble past houses riddled with bullet holes in the eastern city of Benghazi and residents turn out to greet soldiers as they celebrate a rare victory over Islamist insurgents.
"Allah Akbar (God is Great)," shouts a soldier as the tanks set off in pursuit of Islamist fighters fleeing from an army assault in a city engulfed in the chaos that has brought Libya to the brink of civil war in the three years since the fall of Muammar Gaddafi.
The country's nascent army, slowly being put together after Gaddafi's forces were shattered in the NATO-led assault of 2011, has scored a success, although probably only temporary, by seizing back several city districts from the Islamists.
The army's advances in Benghazi will come as a relief to the internationally recognized Prime Minister Abdullah al-Thinni, who was forced to flee to eastern Libya after an armed group with Islamist links took over the capital, Tripoli, and set up a rival government.
The stakes are high for Thinni. If the army is defeated in Benghazi, the Islamist fighters from a group called Majlis al-Shoura will be able to attack army bases further east in Bayda, where Thinni and his cabinet have relocated, and Tobruk, where the elected parliament has set itself up.
The chaotic battle for Benghazi makes clear how Libya is still failing to create a credible army despite Western and Arab countries providing training for hundreds of soldiers.
Since the insurgents seized Tripoli in the summer and forced the elected parliament to flee to the east, the country has had two governments, two parliaments and two army chiefs of staff claiming control over fragmented military formations. An effective defense ministry with national reach has ceased to exist.
That renders foreign training relatively pointless as there is no unified national army to join when the cadets graduate. Some end up with armed groups loyal only to the local commanders who put them forward for the training programs in the first place.
This week, Britain abruptly ended a training program for Libyan soldiers after some of them committed a series of sexual crimes. Others had shown disciplinary problems.
As Libya spins out of control, the best Western countries can hope for now is that the army can reinforce itself by forming alliances with irregular groups of fighters.
That explains why the army's special forces in Benghazi have teamed up with troops loyal to Khalifa Haftar, a general who once served under Gaddafi and who now commands his own military force.
The unlikely alliance was formed after the regular army had waited for over a year for help from Tripoli in fighting increasingly powerful Islamist groups in the area.
Haftar last week sent tanks and artillery from his main base in al-Marj east of Benghazi to join the fighting.
BROTHERS IN ARMS
Members of the special forces and Haftar's men are old comrades-in-arms, since some of them fought together against Gaddafi three years ago. In any case, the army in Benghazi has always been somewhat independent of headquarters in Tripoli.
In May, Haftar launched Operation Dignity, an offensive against the Islamists, which attracted defections from army units sympathetic to his cause. Now the army loyal to Thinni's government has adopted the same name for its operation against the Islamists after the elected parliament signaled support for the former general.
"We special forces all report to the chief of staff Abdel-Razeq Nathouri," said the forces' spokesman Milad al-Zawie. "We get our orders from Tobruk," he added, referring to the seat of the elected parliament allied to Thinni.
Officials stress that Haftar has no official connection with the Benghazi operation but in reality his spokesman Mohamed El Hejazi and the spokesman for the army chief of staff, Ahmed al-Mesmari, both show journalists around the battlefield.
On Thursday, Haftar himself showed up briefly in Benghazi with senior officers to inspect his troops, Hejazi said.
Nathouri is himself an old acquaintance of Haftar, who U.S. officials say receives support from Egypt and the United Arab Emirates, both worried about the spread of Islamists.
Adding to confusion over who is fighting, the army is backed by local youths in civilian clothes riding on Toyota pickups. They attacked street checkpoints set up by Ansar al-Sharia when the military offensive started.
Haftar, who fell out with Gaddafi in 1980s after the Libyan forces he was commanding suffered a disastrous defeat during a war in Chad, has said he wants to retire after "liberating" Benghazi".
But his endgame is not clear. In a video message in February he announced a coup d'etat, though nothing happened. Later he demanded a special council to run the country. Haftar has also drawn support from an armed group in the western town of Zintan which was blamed for an attack on parliament in Tripoli in May.
Nevertheless, many residents are happy that someone is finally taking charge in the city, though the outcome of the battle is far from certain. Fighting is continuing in several areas even though the special forces have retaken barracks they lost in the summer.
Once a beacon of hope for a democratic Libya after the 2011 uprising began in the east, Benghazi now stands for everything that has gone wrong. People must contend with assassinations, carjackings and armed Islamist groups on the streets.
Ansar al-Sharia, blamed by Washington for a 2012 raid in Benghazi that killed the U.S. ambassador, had steadily expanded its influence in the city until the army offensive.
After the army drove back Ansar fighters from some areas, residents couldn't believe what they saw. Traffic police were on duty for the first time in months in a city where many drivers don't even bother to put number plates on their cars.
But life remains tough as most shops have shut, running out of supplies as the port closed. Long queues form at bakeries, while banks are also shut as they receive no banknotes from the central bank.
"The situation is difficult but we have to sit it out," said Ahmed Salim, a 30-year old civil servant.
Ansar al-Sharia, part of Majlis al-Shoura, left the city in 2012 after residents rose up against militias but they came back later. This time some residents hope that the army will prevail.
"The army will win because the street keeps supporting it," said Abdel-Hamid al-Umrauni, a writer. "The Majlis al-Shoura has been beaten."
(additional reporting by Ulf Laessing; writing by Ulf Laessing; editing by Giles Elgood)