Libya's rebels have captured Muammar Gaddafi's son, Saif Al-Islam, the head of the rebel National Transitional Council told Al Jazeera television.
"We have confirmed information that our guys have captured Saif Al-Islam," Mustapha Abd El Jalil said. "We have given instructions to treat him well so that he can face trial."
The claim came as Libyan rebels fought their way into Tripoli, where music played in the streets and residents celebrated.
But leader Muammar Gaddafi refused to surrender even as NATO said his regime was crumbling.
A Libyan government official said 376 people were killed and more than 1000 wounded in the rebel assault on the capital but there was no independent confirmation of the toll.
Libya's defected ex-prime minister Abdessalam Jalloud said he believed it was too late for Gaddafi, his former ally, to strike a deal to leave power and would likely be killed.
An advance party of rebels arrived by sea in the capital early on Sunday and joined sleeper cells of rebels to launch the final push for victory, codenamed "Mermaid", rebel leaders said.
Another rebel force advanced during the day on the capital from the west, moving in a convoy of about 100 vehicles as onlookers fired celebratory gunfire into the air, an AFP correspondent said.
By afternoon they had overrun the eastern suburb of Tajura and boasted that they would seize control of the capital during the night.
A separate rebel party took over an army barracks at a western entrance to Tripoli, raiding the stores of missiles and other ammunition, AFP correspondents said.
They also released dozens of prisoners held in Maya, 25 kilometres west of Tripoli, they said.
"We will enter Tripoli in a few hours. Between now and tomorrow we expect it to fall in our hands," said rebel commander Abdelhakim Belhaj.
A rebel spokesman said the insurgents were also tightening the noose around loyalist forces in the far west of Libya, near the Tunisian border.
Gaddafi, however, refused to relinquish his almost 42-year autocratic grip on power, vowing not to surrender and boasting he would "emerge victorious" in the battle for Tripoli.
"We will not, we will not abandon Tripoli to the occupants and their agents. I am with you in this battle," the Libyan strongman said in a new audio message broadcast on television.
"We do not surrender and, by God's grace, we will emerge victorious."
He called on his supporters to "march on Tajura in tens of thousands to purge the officials of the colonisers", in a reference to the NATO-backed rebels.
"Today we must take over Tajura. I fear, if you let them, they will destroy Tripoli," he warned.
Government spokesman Mussa Ibrahim told reporters "thousands" of professional and volunteer soldiers were defending the capital against rebels, whom he accused of carrying out "34 executions" and raping women in the western coastal town of Sorman.
A fierce gunbattle also broke out near the hotel used by the foreign media in the centre of Tripoli, an AFP correspondent said.
Gunmen loyal to Gaddafi armed with Kalashnikov assault rifles opened fire from the Hotel Rixos towards the east, although their target was not visible.
The initial assault was launched soon after four strong blasts were heard about 4.00am, and while NATO warplanes flew overhead, an AFP journalist said. Gunfire crackled intermittently while more blasts were heard.
The targets were not immediately identifiable but witnesses reported clashes in several districts between insurgents and Gaddafi supporters, especially the eastern suburbs of Soug Jomaa, Arada and Tajura.
NATO said the end was near for Gaddafi.
"What we're seeing tonight is the regime crumbling," chief NATO spokeswoman Oana Lungescu said of the final push for victory in the capital. "The sooner Gaddafi realises there is no way he can win, the better for everyone.
"What you are seeing tonight is the cumulative effect, over time, of the eroded capabilities of the regime," Lungescu said, citing more than 4000 military targets damaged or destroyed in the past four months.
Ex-premier Jalloud said in an interview with Italian news programme TG3 after fleeing Tripoli and escaping first to Tunisia and then Italy in recent days that Gaddafi was trapped.
"He has no way of leaving Tripoli. All the roads are blocked. He can only leave with an international agreement and I think that door is closed," said Jalloud, a former regime stalwart who helped Kadhafi win power in a 1969 coup.
"I think it would be difficult for Gaddafi to give himself up. And he is not like Hitler who had the courage to kill himself ... I don't think the evolution of the situation in Tripoli will allow him to survive," he added.
Gaddafi earlier on Sunday aired a message urging supporters to "march by the millions" to liberate cities held by "traitors and rats".
"These scum enter mosques to cry 'God is great'. They are dirty. They are defiling the mosques," the embattled strongman said in an audio message carried on state television.
Rebel spokesman Ahmed Jibril said Operation Mermaid was a joint effort between the Benghazi-based rebel National Transitional Council (NTC), insurgents fighting in and around Tripoli and NATO forces.
In Dubai, rebel envoy Aref Ali Nayad said the NTC had urged NATO to join the final battle with Apache assault helicopters.
In his eastern stronghold of Benghazi, rebel chief Mustafa Abdel Jalil claimed that victory was within reach, six months after the insurgency was launched.
"We have contacts with people from the inner circle of Gaddafi," the chairman of the NTC said. "All evidence [shows] that the end is very near, with God's grace."
His words prompted celebrations in rebel-held towns, including Sabratha, 50 kilometres west of Tripoli, and in Benghazi, where people crowded in front of television sets to follow the news.
"Goodbye Gaddafi," they chanted in the rebel-capital, Benghazi.
Striking another blow to Gaddafi's regime, Tunisia, Libya's neighbour to the west, on Sunday decided to recognise the NTC as the legitimate representative of the Libyan people, the news agency TAP reported.
A ship chartered by the International Organisation for Migration was to leave for Tripoli from Benghazi during the night to evacuate about 300 foreigners, an IOM official said.
AFP