Near dusk Sunday, members of the Tripoli brigade, a group of rebel fighters from the Libyan capital, were preparing for what they hoped would be the final charge in their campaign to oust Libyan leader Moammar Gaddafi.

They greased their weapons and filled their trucks with gas, and, wearing sandals and shirts in the colors of the red, green and black rebel flag, they pressed on from Zawiyah, the key western city they had taken a day earlier, toward the gates of Tripoli.

But first they would encounter the 32nd Brigade, an elite unit commanded by Khamis Gaddafi, a son of the Libyan leader.

“That is Gaddafi’s first real line of defense for the capital,” said Yussef Mohammadi, who has been training the rebel fighters. “They could be held up for months there,” he said.

The thud of explosions and the crackling sounds of heavy gunfire filled the air, while NATO planes could be heard overhead and ambulances zipped in and out.

But in the end, the rebels met little resistance, even at the military base that was home to the Khamis Brigade.

A NATO airstrike took out several vehicles belonging to Gaddafi’s forces. Next, there was a small firefight, and, in short order, the Libyan military forces fled.

At a nearby crossroads, the rebels fired their weapons in the air to celebrate, as a few hundred haggard men, some weeping with joy, were welcomed as heroes. “They were held for months in an underground prison on the base,” said an older man, who gave only his first name, Murat.

At the base, near the village of Mayah, the charcoaled remains of two Gaddafi fighters lay next to their burned-out pickup truck. The doors of the military camp had been opened, and the rebels had descended on the base like grasshoppers. Steel storage-room doors had been broken in, and hundreds of people were looting whatever they could find.

“Welcome to free Libya!” cried one man, carrying a dozen remote-propelled grenades in his arms. The ammunition depot, a facility the size of a small airport terminal, was filled with pickup trucks all honking to get out, their trunks filled with explosives. Others carried off electricity cables and riot guns; two men were leading away a pair of horses that had been running around on the base.

Tripoli was only a short drive away. “Who are the rats now?” one man asked, making fun of Gaddafi’s nickname for the rebel army. “It is them who are fleeing like rats.”

By midnight, hundreds of rebel fighters had swept toward the heart of Tripoli. Groups of young men from across the city marched to join them, again meeting no resistance from Gaddafi’s military or police.

As the rebels moved past them in trucks, residents of the capital cheered them on. “Libya is free,” they shouted.