TRIPOLI Explosions and gunfire rocked Tripoli overnight, after days of battlefield defeats left Muammar Gaddafi's government and troops penned ever more tightly in the besieged capital.
The fighting inside the city triggered celebrations among some rebels and speculation Gaddafi's 41-year rule was sliding toward collapse. But Gaddafi's officials insisted in the early hours of Sunday the assault had been crushed, a few hours after it began.
Government spokesman Moussa Ibrahim said small groups of armed rebels had infiltrated the capital but had been dealt with.
"I assure Libyans that Gaddafi is your leader ... Tripoli is surrounded by thousands to defend it," he said.
Fighting was still raging around Mitiga airbase in Tripoli's Tajourah district after midnight, an opposition activist told a Reuters journalist outside Libya. The gunbattles had left a number of rebels dead in the suburb of Qadah and elsewhere, he said.
Earlier on Saturday evening, residents told Reuters of gunfire and street protests in several parts of Tripoli.
"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!"
Residents said in the early hours of Sunday that shooting appeared to be subsiding, about four hours after it began.
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 his days are numbered, and reports have emerged of more defections from his ranks. President Barack Obama, on vacation in Martha's Vineyard, was receiving regular updates on Libya, a senior White House official said.
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."
(Additional reporting by Missy Ryan in Tripoli and Robert Birsel in Benghazi, Libya; Souhail Karam in Rabat, Morocco; Writing by Richard Valdmanis and Peter Graff; Editing by Andrew Roche)