One of Col Muammar Gaddafi's sons, Saif al-Islam, has appeared in Tripoli and claimed the government had "broken the backbone" of the rebel offensive there.
He turned up in a government vehicle at a hotel held by loyalists, a day after the rebels said they had detained him.
A BBC correspondent said Saif al-Islam seemed confident and full of adrenalin.
Our correspondent reports renewed gunfire, mortars and grenades in the area around the Rixos hotel, one of the pockets still held by Gaddafi forces.
There are further reports of explosions and heavy artillery around Bab al-Azizia, Col Gaddafi's compound.
Both sides say they control most of the capital.
Saif al-Islam Gaddafi turned up in the early hours of Tuesday at the Rixos Hotel, where many international journalists are based.
He told the BBC: "We have broken the backbone of the rebels." He added that by moving into Tripoli, the rebels had fallen into "a trap".
"We gave them a hard time, so we're winning," he said.
Saif al-Islam Gaddafi, 39, had been widely regarded as a likely successor to his father. On Sunday the rebels claimed they had captured him, along with other members of his family.
On Monday, the chief prosecutor for the International Criminal Court (ICC) said he was negotiating with the rebels for Saif al-Islam's transfer to The Hague.
Saif al-Islam, his father and the head of the Libyan intelligence service have all been indicted for war crimes by the ICC.
But on Tuesday, an ICC spokesman told the BBC that the court had not made any announcement that Saif al-Islam was in its custody. He said the ICC had received different information from the various rebel factions about Saif al-Islam's purported arrest and whereabouts.
UK International Development Secretary Andrew Mitchell blamed the "fog of warfare" for the confusion.
Saif al-Islam said he did not care about the ICC arrest warrant. Asked if Col Gaddafi was safe and in Tripoli, he replied: "Of course."
He also went to his father's Bab al-Azizia compound and told three journalists accompanying him: "Tripoli is under our control. Everyone should rest assured."
In a broadcast late on Sunday, he urged residents to "save Tripoli" from the rebels.
Members of the rebels' National Transitional Council (NTC) in Benghazi say they plan to fly to the capital on Wednesday to start work on forming a new government.
A BBC correspondent in Benghazi says there is optimism in their ranks that by the middle of the week Tripoli airport will be secure enough to allow them to move.
In other developments:
- Pro-Gaddafi forces fired a Scud missile at Misrata, Nato has said; the missile was launched on Monday from the vicinity of Sirte, Col Gaddafi's birthplace
- Col Gaddafi's eldest son Muhammad reportedly escaped from rebel custody hours after being detained
- China and Russia issued statements urging Gaddafi forces to stop fighting
- UN Secretary General Ban Ki-moon said leaders of regional blocs would meet in New York later this week
- Egypt formally recognised the rebel National Transitional Council as the legitimate representative of the Libyan people
The rebels swept into Tripoli at the weekend, but after a swift advance, they met stiff resistance in a number of areas on Monday.
Both sides insist they have the upper hand, but our correspondents Tripoli say the situation is extremely fluid and it is impossible to determine who is telling the truth.
Government spokesman Moussa Ibrahim claimed pro-Gaddafi forces had control of at least 75% of the city, but while the rebels said on Monday night they held almost all of it.
"We are now, I could say, in control of more than 95% of Tripoli," NTC chairman Mustafa Abdul Jalil told the BBC. "The whole forces of Gaddafi disappeared, suddenly disappeared. Only, I think, the brigade of Khamis [Gaddafi, one of the colonel's sons] is still resisting."
World leaders have urged Col Gaddafi to step down. US President Barack Obama said elements of the Gaddafi regime continued to pose a threat.
The uprising against Col Gaddafi's 42-year rule began in February. The rebels held the east of the country and pockets of the west, before making their push towards the capital at the weekend.
Nato air strikes have been targeting Col Gaddafi's troops, acting on a UN mandate to protect civilians.