Members of the Libyan community in Tunisia gather outside the Libyan Embassy in Tunis
Members of the Libyan community in Tunisia gather outside the Libyan Embassy in Tunis August 22, 2011 to celebrate the entry of rebel fighters into Tripoli. Jubilant rebel fighters streamed into the heart of Tripoli as Muammar Gaddafi's forces collapsed and crowds took to the streets to celebrate, tearing down posters of the Libyan leader. Reuters

Libyan government tanks shelled parts of central Tripoli Monday after rebels swept into the heart of the city and crowds took to the streets to celebrate the expected downfall of Muammar Gaddafi.

Tanks emerged from Gaddafi's stronghold in the center of the Libyan capital and were firing shells, a rebel spokesman said. Sporadic gunfire could be heard as world leaders tried to assess how long Gaddafi's forces might hold on and how the fractious rebel alliance might run the oil-rich desert state.

Nouri Echtiwi, a rebel spokesman in Tripoli, told Reuters: Four hours of calm followed the street celebrations. Then tanks and pick-up trucks with heavy machineguns mounted on the back came out of Bab al-Aziziya, the last of Gaddafi's bastions, and started firing and shelling Assarin Street and al-Khalifa area.

They fired randomly in all directions whenever they heard gunfire.

Despite euphoria among rebels and their backers in Tripoli and elsewhere, a rebel spokesman, identified on Al Jazeera television only as Nasser, said government troops still controlled about 15 to 20 percent of the city.

Earlier, rebels waving opposition flags and firing into the air drove into Green Square, a symbolic showcase the government had until recently used for mass demonstrations in support of the now embattled Gaddafi. Rebels immediately began calling it Martyrs Square.

Two of Gaddafi's sons were captured by the rebels, but the whereabouts of Gaddafi himself, one of the world's longest ruling leaders, were unknown.

U.S. President Barack Obama said Gaddafi's rule was showing signs of collapse, six months after dissidents inspired by the Arab Spring uprisings in neighboring Tunisia and Egypt first took to the streets. Obama called on him to quit now to avoid further bloodshed.

Laila Jawad, 36, who works at a Tripoli nursery, told Reuters after the rebels arrived: We are about to be delivered from the tyrant's rule. It's a new thing for me. I am very optimistic. Praise be to God.

REBEL CONVOY

The rebels made their entrance into the capital driving in convoy through a western neighborhood.

Remaining defiant, Gaddafi earlier had made two audio addresses over state television calling on Libyans to fight off the rebels.

I am afraid if we don't act, they will burn Tripoli, he said. There will be no more water, food, electricity or freedom.

But resistance to the rebels initially appeared to have largely faded away, allowing the rebels and their supporters to demonstrate in Green Square overnight.

Near Green Square youths burned the green flags of the Gaddafi government and raised the rebel flag. One rebel fighter from the Western mountain said: We are so happy -- we made it here without any problems.

Many Tripoli residents received a text message from the rebel leadership saying: God is Great. We congratulate the Libyan people on the fall of Muammar Gaddafi.

Gaddafi, a colorful and often brutal autocrat who seized power in a military coup in 1969, said he was breaking out weapons stores to arm the population. His spokesman, Moussa Ibrahim, predicted a violent reckoning by the rebels.

A massacre will be committed inside Tripoli if one side wins now, because the rebels have come with such hatred, such vendetta ... Even if the leader leaves or steps down now, there will be a massacre.

Obama, on vacation in the island of Martha's Vineyard, said in a statement: The surest way for the bloodshed to end is simple: Muammar Gaddafi and his regime need to recognize that their rule has come to an end. Gaddafi needs to acknowledge the reality that he no longer controls Libya. He needs to relinquish power once and for all.

NATO, which has backed the rebels with a five-month bombing campaign, said the transition of power in Libya must be peaceful.

TRIPOLI FALLS QUICKLY

After a six-month civil war that seemed like a stalemate in the desert for long periods, rebels moved quickly into Tripoli, with a carefully orchestrated uprising launched on Saturday night to coincide with the advance of rebel troops on three fronts. Fighting broke out after the call to prayer from the minarets of mosques.

Rebel National Transitional Council Coordinator Adel Dabbechi confirmed that Gaddafi's younger son Saif Al-Islam had been captured. The International Criminal Court in The Hague, which wants Saif al-Islam along with his father on charges of crimes against humanity, confirmed he had been held and said he should be handed over for trial.

Gaddafi's eldest son Mohammed al-Gaddafi had surrendered to rebel forces, Dabbechi told Reuters. In a television interview, the younger Gaddafi said gunmen had surrounded his house, but he later told Al-Jazeera in a phone call that he and his family were unharmed.

Only five months ago Gaddafi's forces were set to crush the rebel stronghold of Benghazi in the far east of the vast and thinly populated North African state. He warned then that there would be no mercy, no pity for his opponents. His forces, he said, would hunt them down district to district, street to street, house to house, room to room.

The United Nations then acted quickly, pushed notably by French President Nicolas Sarkozy, clearing the way for the creation of a no-fly zone that NATO, with a campaign of bombing, used ultimately to help drive back Gaddafi's forces.

It's over. Gaddafi's finished, said Saad Djebbar, former legal adviser to the Libyan government.

In Benghazi, thousands gathered in a central square. They waved red, black and green opposition flags which date from the time of Libya's post-colonial monarchy and trampled on pictures of Gaddafi as news filtered through of rebel advances into Tripoli.

Mohammed Derah, a Libyan activist in Tripoli, told Al-Jazeera: This is another day, a new page in Libya's history. We are witnessing a new dawn and a new history of freedom. The regime is finished.

Celebratory gunfire and explosions rang out over the capital and cars blaring their horns crowded onto the streets. Overhead, red tracer bullets darted into a black sky.

It does look like it is coming to an end, said Anthony Skinner, Middle East analyst, Maplecroft. But there are still plenty of questions. The most important is exactly what Gaddafi does now. Does he flee or can he fight?

In the slightly longer term, what happens next? We know there have been some serious divisions between the rebel movement and we don't know yet if they will be able to form a cohesive front to run the country.

Gaddafi, in his second audio broadcast in 24 hours, dismissed the rebels as rats.

I am giving the order to open the weapons stockpiles, Gaddafi said. I call on all Libyans to join this fight. Those who are afraid, give your weapons to your mothers or sisters.

Go out, I am with you until the end. I am in Tripoli. We will ... win.

A Libyan government official told Reuters that 376 people on both sides of the conflict were killed in fighting overnight on Saturday in Tripoli, with about 1,000 others wounded.

(Reporting by Missy Ryan in Tripoli, Robert Birsel in Benghazi, Libya, William Maclean in London, Hamid Ould Ahmed in Algiers, Souhail Karam in Rabat, Laura MacInnis and Alister Bull in Oak Bluffs, Mass.; Writing by Christian Lowe, Richard Valdmanis and Giles Elgood; Editing by Michael Roddy and Alastair Macdonald)