It was unclear who was carrying out the shooting, which started at about 5:45am (0345 GMT) on Sunday, or what caused it, Anita McNaught, Al Jazeera's correspondent in the capital, said.
Automatic weapon rounds, some of it heavy calibre, echoed around central Tripoli along with pro-government chants and whistling and a cacophony of car horns as vehicles sped through the vicinity, witnesses said.
However, a government spokesman denied any fighting was under way in Tripoli. "I assure you, I assure you, I assure you, I assure you, there is no fighting going on in Tripoli," Mussa Ibrahim told the Reuters news agency.
"Everything is safe. Tripoli is 100 per cent under control. What you are hearing is celebratory fireworks. People are in the streets, dancing in the square."
Tripoli is the main stronghold of Libyan leader Muammar Gaddafi, who is facing a sustained rebellion that has posed the biggest challenge ever to his more than 41-year-old rule.
The show of force comes a day after anti-government fighters in the western Libyan town of Az-Zawiyah repelled repeated attacks by forces loyal to Gaddafi.
Gaddafi's forces encircled Az-Zawiyah on Saturday, manning checkpoints about 3km from the centre after fighters pushed them back in fierce fighting earlier in the day.
Troops later mounted a second attack on the town, which lies just 50km west of the capital Tripoli, but were again pushed back.
More than 30 people were killed and as many as 200 people were said to have been wounded in the fighting that drove government forces out of the town.
Youssef Shagan, a spokesman for the fighters in the town, said that Gaddafi's forces had entered Az-Zawiyah at 6am (04:00 GMT) with hundreds of soldier, along with tanks and armoured vehicles.
Gaddafi's forces had broken through defences into Martyrs' Square, in the heart of the town, but hours later were pushed back.
"Our people fought back ... We have won for now and civilians are gathering in the square," Shagan said.
Elsewhere, anti-government forces were in control of Ras Lanuf, which houses a major refinery and petrochemical complex, and the nearby town of Bin Jawad.
The area is significant because it takes the fighters closer to Sirte, a Gaddafi stronghold.
Hoda Abdel-Hamid, Al Jazeera's correspondent who had visited the area, said: "I have to say on the road all I've seen was convoy after convoy - a mixture of volunteers, fighters and regular soldiers making their way to Ras Lanuf and past Ras Lanuf.
"They are regrouping there. They are very proud of all the gains they've made - they say they are going straight to Sirte, and after Sirte to Tripoli."
A report from the Reuters news agency said that one of its correspondents was shown the wreckage of a warplane in the area of Ras Lanuf that fighters said they had shot down.
In Benghazi, Libya's second city which is in the hands of anti-government forces, the self-declared opposition national council, held their first meeting on Saturday.
The 30-member body is headed by Mustafa Abdel Jalil, a former justice minister who defected from Gaddafi's camp after protests against the Libyan leader's rule erupted two weeks ago. The meeting was held in secret.
The group later announced it had set up a crisis committee, to be headed by Mahmoud Jebril, one of a group of intellectuals who had called for a democratic state.
Omar Hariri, one of the officers who took part in Gaddafi's 1969 coup but was later jailed, was appointed head of military affairs and Ali Essawi, a former ambassador to India who quit last month, was put in charge of foreign affairs.
'Call to arms'
Tony Birtley, Al Jazeera's correspondent reporting from Benghazi, said that resistance to Gaddafi's rule was strengthening.
"I think they're coming to the realisation that the outcome is in their own hands. They did think that Gaddafi would leave peacefully, they then thought that the international community would take steps and force him out," he said.
"I think the pendulum has swung now and they believe it is in their own hands.
"They are answering the call to arms, they are coming from all over eastern Libya, bringing their weapons, getting whatever training they can and moving on."
Gaddafi has had little success in taking back rebel-held territory - which includes the entire eastern half of the country and some cities near the capital - but a number of cities, including Tripoli, remain firmly under his control.
Human rights groups say about 6,000 people have been killed since protests against Gaddafi erupted on February 15. The UN says that more than 1,000 have died.
Western powers say they are studying a no-fly zone against Libya to prevent attacks on civilians.
But diplomats say that no official request for such action has been made to the UN Security Council.
Source:Al Jazeera and agencies