By William Maclean and Emma Farge
TRIPOLI (Reuters) - Libya's neighbor Tunisia jailed Muammar Gaddafi's former prime minister on Thursday, and Libya's new rulers said they were tightening their grip on the desert towns where Gaddafi himself may be hiding.
In the highest profile detention of a Gaddafi associate to date, a Tunisian court sentenced ex-prime minister Al Baghdadi Ali al-Mahmoudi to six months in jail on charges of illegally entering the country on Wednesday evening.
"Al-Mahmoudi was arrested yesterday evening," a Tunisian Interior Ministry official, speaking on condition of anonymity, told Reuters.
"(He) was arrested because he entered Tunisian territory illegally ... He did not have an entry stamp in his passport."
The justice minister in Libya's new government said Tripoli would request that the former prime minister be extradited to stand trial in Libya.
"Baghdadi directly oversaw the operations which had to do with the killings of Libyans," the minister, Mohammed al-Alagi, said on Al Arabiya television station.
The National Transitional Council (NTC), Libya's de facto government since Gaddafi was swept from the capital last month, has been anxious to show that it can establish firm control over a country riven by tribal and regional rivalries.
The new government said it was consolidating its grip on Sabha and other oasis towns in the far south of the country which had sided with Gaddafi.
"Our revolutionaries are controlling 100 percent of Sabha city, although there are some pockets of resistance by snipers," NTC military spokesman Ahmed Bani told reporters in the capital, Tripoli.
"This resistance is hopeless ... They know very well that at the end of the day they will show the white flag or they will die. They are fighting for themselves, not for the tyrant," he said, referring to Gaddafi.
Until now some parts of Sabha, the traditional base for Gaddafi's own tribe about 800 km (500 miles) south of Tripoli, had been occupied by fighters loyal to him.
The council says its forces have now also taken control of Jufra, to the north-east of Sabha, and the nearby oasis towns of Sokna, Waddan, and Houn.
The NTC official said the manhunt for Gaddafi, in hiding for weeks though he occasionally issues defiant audio messages, was drawing closer to its target.
"There is no whole tribe or city on Gaddafi's side," said Bani. "I'm asking everyone in the south who has any news about the tyrant or his loyalists ... to notify the legal bodies about them."
"We are doing our best looking for the tyrant. There is some news here and there that he ran away from Sabha to another place but it cannot be confirmed."
In Tripoli on Thursday, the U.S. ambassador returned to work after a hiatus caused by the civil war, and predicted a quick end to the fighting.
"I think it is a matter of time (for) Gaddafi and his remaining loyalists. Their resistance is finished," Ambassador Gene Cretz told reporters at a ceremony to mark the re-opening of the U.S. mission.
Libya's interim government received a diplomatic boost when its neighbor Algeria recognized the NTC as the country's legitimate representative, according to a report broadcast by Al Arabiya.
Algeria was the last of Libya's neighbors to grant recognition, and the two sides have for months been trading allegations.
The NTC accused Algiers of abetting Gaddafi in the civil war, and Algeria said it was worried the new government was not firm enough on the threat from Islamist militants.
Western security officials say good relations between Libya and Algeria are vital if they are to keep a lid on al Qaeda's north African branch, which has kidnapped foreigners and attacked Western targets in the region.
The country's new rulers were faring less well on the battlefield, aside from advances in the far south.
In the two biggest towns where Gaddafi loyalists are still holding out, Sirte and Bani Walid, the NTC's offensive has been chaotic, raising fresh questions about the council's ability to run the oil exporting country effectively.
Despite support from NATO warplanes, government forces have struggled to capture Sirte, Muammar Gaddafi's hometown and the biggest of the towns still outside their control.
It is a thorny task because the sympathies of many residents lie with Gaddafi. The city typifies the challenges the NTC faces in reconciling the significant parts of the country that have tribal loyalties to Gaddafi or did not support the revolution.
A spokesman for Gaddafi told Reuters on Thursday that NATO air strikes and interim government forces' shelling of Sirte were killing civilians.
"Between yesterday and this morning, 151 civilians were killed inside their homes as the Grad rockets and other explosives fell upon their heads," Moussa Ibrahim said in a satellite phone call to Reuters from an undisclosed location.
His claims could not be verified as journalists are unable to reach the city. NATO comment was not immediately available.
There was a counter-claim from rebel fighters near Sirte, and from residents fleeting the city, who said that pro-Gaddafi forces had been executing people suspected of sympathizing with the NTC forces.
An NTC commander on the outskirts of Sirte, who gave his name as Saleh, showed Reuters a handwritten list of families whose members were said to have been executed in Sirte.
"One man, they cut him like this," the commander said, dragging his finger from the ends of his mouth across his cheeks. "Another, they cut his lips."
On the Western outskirts of Sirte on Thursday there was little fighting, and dozens of civilians poured out of the city through anti-Gaddafi checkpoints. Over on the eastern side of the city, NTC forces came under heavy artillery fire.
One fighter there said pro-Gaddafi artillery batteries appeared to have found the range of the NTC tanks, positioned more than 50 km east of Sirte, and were targeting them.
"There has been heavy shelling from Gaddafi forces," said Adel Al-Tarhouni, an anti-Gaddafi fighter in the village of Sultana, which came under artillery attack. "I was able to see palm trees cut from the top by the shrapnel."
LACK OF Organization
North of Bani Walid, NTC military forces brought forward tanks and Grad rocket launchers in preparation for a renewed attempt to take the town. It was not clear when that attack might begin.
Later in the day, a Reuters reporter near the town said fighting had resumed after a lull, though it did not appear to be an all-out assault.
Gaddafi loyalists were firing shells at NTC positions on the edge of the town, and plumes of smoke could be seen rising up from within Bani Walid.
The offensive there has been frustrated by stiff resistance from well-drilled loyalist fighters, and also by a lack of organization among the NTC forces. They operate in disparate units based on their home towns, with little overall command.
On Wednesday, one fighter shot his own head off and killed another fighter while handling a rocket-propelled grenade in full view of a Reuters team. In another incident, a fighter wounded himself and another fighter after losing control of his machinegun.
The nascent NTC national army has tried to bring order.
If the NTC is unable to swiftly assert its control over the country and its own forces, it could embarrass Western leaders, especially France's Nicolas Sarkozy and Britain's David Cameron, who took a gamble by backing the anti-Gaddafi leadership.
"We have set up a unified operations room to unite all brigades," said brigade commander Omar Kabout. "The purpose is to increase coordination and end all this chaos because many rebels have arrived without commanders. We need to put them into brigades and stop all this random shooting."
But the message was not getting through to all the fighters, many of whom go into battle wearing flip-flop sandals, T-shirts and jeans and have no military training.
"We don't take orders from the NTC. We listen only to our own commander," said Ziyad Al Khemri, a fighter from the town of
Zawiyah, just west of Tripoli.
(Reporting by Tarek Amara in Tunis, Emma Farge in Tripoli, Maria Golovnian north of Bani Walid, Sherine El Madany east of Sirte, Alexander Dziadosz west of Sirte and Hamid Ould Ahmed in Algiers and Dina Zayed in Cairo; Writing by Christian Lowe; Editing by Roger Atwood)