TRIPOLI, Libya — Heavy fighting was reported near Moammar Gadhafi's compound Monday as government forces launched a fightback after rebels swept into the heart of the Libyan capital and crowds took to the streets to celebrate what they saw as the end of the dictator's four decades in power.
Rebel spokesman Mohammed Abdel-Rahman said tanks emerged from the complex, known as Bab al-Aziziya, and began firing shortly after dawn.
Nouri Echtiwi, another rebel spokesman in Tripoli, told Reuters: "Four hours of calm followed the street celebrations. Then tanks and pick-up trucks with heavy machine guns mounted on the back came out of Bab al-Aziziya ... and started firing and shelling. They fired randomly in all directions whenever they heard gunfire."
Tripoli resident Moammar al-Warfali, whose family home is next to Bab al-Aziziya, said tanks rolled out from the compound after a group of rebels tried to get in. He said there appeared to be only a few tanks belonging to the remaining Gadhafi forces that have not fled or surrendered.
Bab al-Aziziya, a sprawling compound that long served as the command center for the regime, has been heavily damaged by repeated NATO airstrikes over the past five months.
A rebel spokesman also told Al-Jazeera that some pro-Gadhafi forces were still fighting and controlled 15 to 20 percent of Tripoli.Story: With Gadhafi out of power, oil prices should fall
Two of Gadhafi's sons were captured by the rebels but the whereabouts of Gadhafi himself, one of the world's longest ruling leaders, were unknown.
Earlier, rebels waving opposition flags and firing into the air drove into Green Square, a symbolic showcase of the government until it was recently used for mass demonstrations in support of Gadhafi. Rebels immediately began calling it Martyrs' Square.
Hundreds of people remained in the streets of the capital Monday morning. Many of them were armed, and they fired repeatedly at propaganda posters of Gadhafi.
The startling rebel breakthrough, after a long deadlock in Libya's 6-month-old civil war, was the culmination of a closely coordinated plan by rebels, NATO and anti-Gadhafi residents inside Tripoli, rebel leaders said.Story: 'Libya will go down in history as the anti-Iraq'
Rebel fighters from the west swept over 20 miles in a matter of hours Sunday, taking town after town and overwhelming a major military base as residents poured out to cheer them. At the same time, Tripoli residents secretly armed by rebels rose up.
President Barack Obama said in a statement late Sunday from vacation in Martha's Vineyard, Mass., that "Tripoli is slipping from the grasp of a tyrant" and that Gadhafi's regime "is showing signs of collapsing."
"The future of Libya is now in the hands of the Libyan people," the president said.
Gadhafi delivered a series of defiant audio messages on state television Sunday night. He acknowledged that the opposition forces were moving into Tripoli and warned that the city would be turned into another Baghdad.
"The traitors are paving the way for the occupation forces to be deployed in Tripoli," he said, calling on his supporters to march in the streets of the capital and "purify it" from "the rats."Libya's Internet flickers back to life
Al-Jazeera's Arabic-language service reported that officers who had defected to the rebels found Gadhafi overnight near Tajoraa Hospital east of Tripoli. Gadhafi resisted, and two of the officers who tried to arrest him were killed, said the news agency, quoting a military source.
Another major Arabic news agency, Al Arabiya, reported that indications were that Gadhafi may be in Tajoraa Hospital.Video: Libyan transition group: Gadhafi must be captured alive (on this page)
NBC News was not able to independently confirm the reports. Other top officials were reported to be fleeing, led by Prime Minister Al Baghdadi AlMahmoudi, who was spotted Monday morning in Jaraba, Tunisia, Al-Jazeera reported.
As international news agencies broadcast video of huge crowds celebrating in Benghazi, the rebels' eastern headquarters, a U.S. official told NBC News that "the battle for Tripoli is clearly under way, and what has often seemed impossible — the fall of Gadhafi — may now be attainable."
Referring to news that Gadhafi's sons Seif al-Islam, his onetime heir apparent, and Mohammed had been arrested and were in rebel custody, the U.S. official said, "We could be watching the game changer unfolding."
"Whether or not Gadhafi reads the tea leaves the same way is the big question," the official said.
'Time for justice, not revenge'
Citing a source close to Gadhafi's inner circle, NBC News reported that Seif al-Islam had tried to flee Tripoli while disguised as a women.
In the Netherlands, the prosecutor at the International Criminal Court, Luis Moreno-Ocampo, said his office would talk to the rebels on Monday about Seif al-Islam's transfer for trial. "It is time for justice, not revenge," Moreno-Ocampo told the AP.
Seif al-Islam, his father and Libya's intelligence chief were indicted earlier this year for allegedly ordering, planning and participating in illegal attacks on civilians in the early days of the violent crackdown on anti-regime protesters.
P.J. Crowley, former chief spokesman for the State Department, said in an interview with msnbc TV that the swift takeover of the capital was "simply remarkable."
Crowley cautioned that the world community would need to act just as swiftly to ensure stability. The National Transitional Council, a committee formed in March by anti-Gadhafi forces, has been "preparing for this day," but it would have been surprised by the overnight takeover, he said.Video: US to Libya's transition council: Get ready (on this page)
"They will have to move swiftly," Crowley said, asking: "What will happen to their security services? ... What kind of justice system will we have?"
Earlier Sunday, the rebels overran a major military base defending the capital, carted away truckloads of weapons and raced to Tripoli with virtually no resistance.
The rebels' surprising and speedy leap forward was packed into just a few dramatic hours. By nightfall, they had advanced more than 20 miles to Gadhafi's stronghold.Story: Can anyone unite Libya if Gadhafi falls?
Thousands of jubilant civilians rushed out of their homes to cheer the long convoys of pickup trucks packed with rebel fighters shooting into the air. Some were hoarse, shouting, "We are coming for you, frizz-head," a mocking nickname for Gadhafi. In villages along the way that fell to the rebels one after another, mosque loudspeakers blared, "Allahu Akbar," or "God is great."
"We are going to sacrifice our lives for freedom," Nabil al-Ghowail, 30, a dentist, said as he held a rifle in the streets of Janzour, a suburb just 6 miles west of Tripoli. Heavy gunfire erupted nearby.
As town after town fell and Gadhafi forces melted away, the mood turned euphoric. Some shouted: "We are getting to Tripoli tonight." Others were shooting into the air, honking horns and yelling "Allahu Akbar."
Once the rebels reached Tripoli, a convoy of more than 10 trucks entered the neighborhood of Ghot Shaal on the western edge of the city and set up checkpoints.
The rebels moved on to the neighborhood of Girgash, about a mile and a half from Martyrs Square. They said they came under fire from a sniper on a rooftop in the neighborhood.
Sunday's first breakthrough came when hundreds of rebels fought their way into a major symbol of the Gadhafi regime — the base of the elite 32nd Brigade, commanded by Gadhafi's son Khamis. Fighters said they met little resistance.
Hundreds of rebels cheered wildly and danced as they took over the compound filled with eucalyptus trees, raising their tricolor from the front gate and tearing down a large billboard of Gadhafi.Slideshow: Moammar Gadhafi through the years (on this page)
Inside, they cracked open wooden crates labeled "Libyan Armed Forces" and loaded their trucks with huge quantities of munitions. One of the rebels carried off a tube of grenades, while another carted off two mortars.
Across the street, rebels raided a huge warehouse, making off with hundreds of crates of rockets, artillery shells and large-caliber ammunition. The warehouse had once been used to store packaged foods, and in the back, cans of beans were still stacked toward the ceiling.
The prisoners had been held in the walled compound, and when the rebels rushed in, they freed more than 300 of them.
"We were sitting in our cells when, all of a sudden, we heard lots of gunfire and people yelling 'Allahu Akbar.' We didn't know what was happening, and then we saw rebels running in and saying, 'We're on your side.' And they let us out," said Majid al-Hodeiri, 23, of Zawiya. He said he was captured four months ago by Gadhafi's forces and taken to the base, where he said he was beaten and tortured.
Many of the prisoners looked disoriented as they stopped at a gathering place for fighters several miles away from the base. Some had signs of severe beatings. Others were dressed in tattered T-shirts or were barefoot.
Crackdown fuels rebellion
The uprising against Gadhafi broke out in mid-February, and anti-regime protests quickly spread across the vast desert nation of 6 million people. A brutal regime crackdown quickly transformed the protests into an armed rebellion. Rebels seized Libya's east, setting up an internationally recognized transitional government there, and two pockets in the west, the port city of Misrata and the Nafusa mountain range.
Gadhafi clung to the remaining territory, and his forces failed to subdue the rebellion in Misrata, Libya's third-largest city, and in the Nafusa mountains. Since the start of August, thousands of rebel fighters, including many who had fled Gadhafi-held cities, joined an offensive that was launched from the mountains toward the coast.
The fighters who had set out from the mountains three weeks ago rushed toward Tripoli on Sunday, starting out at dawn from a village just east of the coastal city of Zawiya. Only a day earlier, the rebels had claimed full control of Zawiya, an anti-regime stronghold of 200,000 people and home to Libya's last functioning oil refinery.
Rebels said Saturday that they had launched their first attack on Tripoli in coordination with NATO, and gunbattles and mortar rounds rocked the city. NATO aircraft also made heavier-than-usual bombing runs after nightfall, with loud explosions booming across the city.
NATO has conducted airstrikes in Libya since the end of March to fulfill a U.N. mandate calling for military action to protect civilians. Oana Lungescu, a NATO spokeswoman, said the Western alliance would continue to enforce its mandate.
NBC News' Richard Engel, Andrea Mitchell, Courtney Kube, Jim Maceda, Kristen Welker, msnbc TV's Chris Jansing, The Associated Press, Reuters and msnbc.com staff contributed to this report.