Rebel fighters sped back on forth on gun trucks and comrades squeezed off celebratory rounds, even as incoming fire, possibly rockets or mortar rounds, was falling nearby, blowing up patches of sand. Smoke billowed from the direction of Bani Walid.
The chaotic scene was jarringly reminiscent of the disorderly fighting in the country's east in March and April, when enthusiastic rebels raced forward on pickups mounted with rocket launchers and antiaircraft guns, only to hasten back to their lines in the face of fire from Moammar Kadafi's forces.
Libya's new leaders are keen to consolidate control of the country and launch the political process that is designed to lead to elections and a constitution. But that process cannot begin until remaining Kadafi strongholds such as Bani Walid are incorporated into the transitional government.
The fighters' hope of a swift victory in Bani Walid was dashed at least temporarily Saturday when they were forced to retreat in the face of strong resistance from pro-Kadafi loyalists in the Libyan desert town.
After advancing into the city Friday, fighters facing snipers and rockets beat a path back to a desert valley that became a makeshift staging base about two miles north of Bani Walid.
The insurgents managed to take Tripoli, the capital, last month with astonishing speed, as rebel units from the western mountains and the coastal city of Misurata joined with internal Tripoli guerrilla "brigades" that also rose up against Kadafi's rule. Many of Kadafi's troops declined to fight.
However, the rebels have had less success with set-piece attacks on well-defended cities such as Bani Walid, where Kadafi's troops appear to be dug in and internal opposition has been suppressed.
Several rebels said Saturday that they had been told to pull back from Bani Walid in anticipation of NATO airstrikes, but a NATO official in Naples, Italy, denied that there was any "coordination" of the rebel advance and the alliance's aerial operations. The official did confirm NATO activity in the Bani Walid area, and at least one aircraft, possibly a drone, could be seen high over the battle zone.
North Atlantic Treaty Organization bombardments have pounded Bani Walid and other towns still in Kadafi's camp.
Hundreds of the former leader's best-trained and most loyal troops may be holed up in Bani Walid, about 90 miles southeast of Tripoli, preparing a desperate defense, rebel leaders said.
"Kadafi wants to fight to the end," said Abdullah Kanshil, a rebel negotiator who tried unsuccessfully to broker a surrender of Bani Walid. "He wants for people to fight each other and inflict as much pain as he can."
A pro-Kadafi commander from the town refused talks with the rebels, Kanshil said, demanding to speak with NATO representatives instead.
Among those seen recently in Bani Walid, Kanshil said, were two of Kadafi's sons and the ousted leader's former chief spokesman, Musa Ibrahim.
Kadafi is said to have lavished money and patronage on the city of 100,000 in a bid to secure support from Libya's largest tribe, the million-strong Warfallah, which is based in Bani Walid.
Rebel officials had voiced confidence in a quick victory in the town before attacking Friday. But Saturday's action indicated that the siege could last awhile. At least two rebels were reported killed.
As the fighting went on in Bani Walid, the head of Libya's transitional administration, Mustafa Abdul Jalil, arrived in Tripoli for the first time since the rebel victory in the capital. His absence had sown doubt about the ability of Libya's new leaders to run the North African nation.
In the spring, rebel sieges of heavily defended Port Brega in eastern Libya and Zlitan outside Misurata dragged on for weeks before fighters could punch through.
Rebel officials hope the same protracted scenario doesn't unfold here and at two other major Kadafi strongholds: the coastal city of Surt, Kadafi's hometown, and the southern municipality of Sabha, deep in the Sahara. More than a dozen rebels were reported killed Friday in rocket attacks from Surt.
A rebel commander near Bani Walid, Daw Jedik, called on the city's defenders to lay down their arms, vowing that "no harm" would come to those who relinquished their weapons.
"We would like to see the people of Bani Walid make their own uprising against the tyrant," said Abdul Mola Mohammed, a businessman turned rebel volunteer from the Tripoli suburb of Tajoura.
But no revolt threatening Kadafi's rule has yet materialized in Bani Walid. Many Bani Walid residents have fled the besieged town, which has no running water, electricity, gasoline or telephone service, rebel officials said.
"I'm afraid this battle could last awhile," said a volunteer rebel doctor, Rajab Zarriug, 26, who was sitting in an ambulance awaiting casualties near the rebel front line.
The town is equally divided between Kadafi backers and rebel supporters, said the doctor, whose family comes from Bani Walid. "But Kadafi's people have the guns."
The rebel volunteers massed outside Bani Walid appeared frenzied and ill-organized, though none seemed to lack fighting spirit.
As he drove a gun truck ferrying half a dozen rebels armed with Kalashnikov rifles toward Bani Walid, Ahmed Sharif, 20, shouted: "We win or we die!"