Explosions and gunfire rocked Tripoli on Saturday night, after days of battlefield defeats left Muammar Gaddafi's government and troops penned ever more tightly in the besieged capital.
The scale of the unrest was unclear, but speculation was rife that Gaddafi's 41-year rule was close to collapse.
Tripoli residents told Reuters there were anti-Gaddafi protesters in the streets.
"We can hear shooting in different places," said one. "Most of the regions of the city have gone out, mostly young people.... it's the uprising... They went out after breaking the [Ramadan] fast."
"They are shouting religious slogans: God is greatest!"
Government spokesman Moussa Ibrahim told state television, however: "All of Tripoli is safe and stable."
A text message was sent to phones in Tripoli, apparently from pro-Gaddafi forces: "Masses of the heroic Libyan people in all Libyan cities, you are asked to go out into the squares and streets to eliminate armed agents."
This week's rebel advances on Tripoli have transformed the war by cutting the capital off from its main road link to the outside world and putting unprecedented pressure on Gaddafi.
Washington says the veteran leader's days are now numbered, and reports have emerged of more defections from his ranks.
The six-month-old war came close to the Tunisian frontier after rebels suddenly seized the coastal city of Zawiyah just 50 km (30 miles) west of Tripoli, surrounding the heavily fortified capital and severing its vital supply routes.
In Tunisia, security sources said their forces had intercepted Libyan men in vehicles with weapons and fought them through the night in the desert. They reported several casualties, but did not say whether the fighters were Libyan rebels or pro-Gaddafi soldiers cut off from Tripoli.
Residents of the southern Tunisian desert town of Douz told Reuters by telephone that helicopters were swooping overhead and troops had been summoned from nearby towns to subdue the infiltrators, who rode in vehicles without number plates.
The imposition of a siege around Tripoli has trapped its residents and cut it off from fuel and food supplies. The International Organization for Migration said on Friday it would organize a rescue operation to evacuate thousands of foreign workers, probably by sea.
Intense fighting continued in Zawiyah, home to an important oil refinery, on Saturday and rebels occupying the center of the city said pro-Gaddafi forces showed no sign of retreat.
"Gaddafi will try to take back Zawiyah at any price. He will keep shelling the hospital," said a rebel fighter as he prepared for midday prayers in the mosque of Bir Hawisa, a nearby village where many civilians are sheltering.
"We will not let that happen. We will fight."
East of Tripoli, fighting has been bloodier and rebel advances far slower. On Friday, opposition forces fought street battles in the city of Zlitan but suffered heavy casualties, a Reuters reporter said. A rebel spokesman said 32 rebel fighters were killed and 150 wounded.
NATO warplanes have hammered Gaddafi military targets since March under a U.N. mandate to protect civilians. Gaddafi's government has said the bombs have killed scores of innocent people, including 27 during a raid on Tripoli this week.
On Saturday, Libyan Prime Minister Al Baghdadi Ali Al-Mahmoudi spoke to U.N. General Secretary Ban Ki-moon by telephone requesting an investigation into alleged abuses by NATO, Libyan state news agency JANA reported.
JANA said Ban had promised to study the proposal.
In another potential blow to Gaddafi, a Tunisian source said Libya's top oil official, Omran Abukraa, had arrived in Tunisia after deciding not to return to Tripoli from a trip to Italy.
If confirmed, it would be the third apparent defection of a senior Gaddafi associate this week. A senior security official arrived in Rome on Monday, and rebels said on Friday that Gaddafi's estranged former deputy Abdel Salam Jalloud had joined their side in the western mountains.
The siege of Tripoli and the prospect of a battle for the capital have added urgency to the question of Gaddafi's fate. The leader has repeatedly vowed never to leave the country and rebels say they will not stop fighting until he is gone.
A senior U.S. official said on Saturday that the opposition must prepare to take over power soon. The United States is among more than 30 nations that have recognised the rebels' National Transitional Council (NTC) as Libya's legitimate authority.
"It is clear that the situation is moving against Gaddafi," U.S. assistant Secretary of State Jeffrey Feltman told a news conference after meeting Libyan rebel leaders at their headquarters in Libya's eastern city of Benghazi.
"The opposition continues to make substantial gains on the ground while his forces grow weaker."