A convoy of rebels entered a western neighbourhood of the city, firing their weapons into the air. Rebels said the whole of the city was under their control except Qaddafi's Bab Al-Aziziya-Jazeera stronghold, according to al-Jazeera Television.
Qaddafi 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."
Qaddafi, a colourful and often brutal autocrat who has ruled Libya for over 40 years, 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."
NATO, which has backed the rebels with a bombing campaign, said the transition of power in Libya must be peaceful.
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. His eldest son Mohammed Al-Qaddafi had surrendered to rebel forces, he told Reuters.
Only five months ago Qaddafi's forces were set to crush the rebel stronghold of Benghazi, the leader warning in a television address 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 Qaddafi's forces.
"It's over. Qaddafi's finished," said Saad Djebbar, former legal adviser to Libyan government.
Al Jazeera television aired images of people celebrating in central Tripoli and tearing down posters of Qaddafi, which had dominated Libyan cities for decades.
In Benghazi in the east, thousands gathered in a city-centre square waving red, black and green opposition flag 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."
Qaddafi, in his second audio broadcast in 24 hours, dismissed the rebels as rats.
"I am giving the order to open the weapons stockpiles," Qaddafi 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.
(Additional reporting by Missy Ryan in Tripoli, Robert Birsel in Benghazi, Libya, William Maclean in London, Hamid Ould Ahmed in Algiers; Writing by Christian Lowe and Richard Valdmanis; Editing by Andrew Roche)