Libyan rebel fighters
Libyan rebel fighters ride through the town of Maia celebrating after advancing to the outskirts of Tripoli, August 21, 2011. Bob Strong

Jubilant rebel fighters swept into the heart of Tripoli Sunday night as Muammar Gaddafi's forces collapsed and crowds took to the streets to celebrate the apparent downfall of his 42-year rule.

Rebels waving opposition flags and firing into the air drove into Green Square, where the government had staged mass demonstrations in support of Gaddafi. They immediately began calling it Martyrs Square.

U.S. President Barack Obama said Gaddafi's rule was showing signs of collapse and called on him to quit now to avoid further bloodshed.

Laila Jawad, 36, who works at a Tripoli nursery, tolf Reuters: 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.

The rebels made their entrance into the capital driving in convoy through a western neighborhood. They later said the whole of the city was under their control except Gaddafi's Bab Al-Aziziyah stronghold, according to al-Jazeera television.

Two of Gaddafi's sons were captured by the rebels, who were also reported to have seized the state radio building. Gaddafi's presidential guard reportedly laid down their arms.

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 by his forces appeared to have largely faded away, allowing the rebels and their supporters to overrun Green Square.

Libyans kissed the ground in gratitude for what some called a blessed day.

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 had said he was breaking out weapons stores to arm the population. His spokesman, Moussa Ibrahim, predicted a violent reckoning.

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, Mass., 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 bombing campaign, called for a peaceful transition of power.

TRIPOLI FALLS QUICKLY

After a six-month civil war, the fall of Tripoli came quickly, 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 the 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 along with his father on charges of crimes against humanity, 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, the leader warning 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, clearing the way for 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 in the east, tens of thousands gathered in a city-center square waving red, black and green opposition flags and trampling on pictures of Gaddafi as news filtered through of rebel advances into Tripoli.

It's over! shouted one man as he dashed out of a building, a mobile telephone clutched to his ear. Celebratory gunfire and explosions rang out over the city 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.

A diplomatic source in Paris, where the government has closely backed the rebels, said underground rebel cells in the capital had been following detailed plans drawn up months ago and had been waiting for a signal to act.

That signal was iftar -- the moment when Muslims observing the holy months of Ramadan break their daily fast. It was at this moment that imams started broadcasting their message from the mosques, residents said.

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