Rebel fighters are in control of the centre of the town of Zawiyah, about 50km west of the Libyan capital, a Reuters reporter in Zawiyah said.
The reporter said he could see about 50 rebels near Zawiyah's main produce market with the red, black and green rebel flag flying from a shop.
Rebel fighters told Reuters there were still forces loyal to Libyan leader Muammar Gaddafi in the town, including snipers. The sound of occasional gunfire could be heard, but no heavy fighting.
The position is the closest the rebel frontline has been to Tripoli since the uprising against Gaddafi began.
Holding Zawiyah would give the rebels control of the coastal highway, the main link between the capital and the outside world.
The government confirmed fighting in the area but said a rebel attempt to capture Zawiyah had been beaten back.
Zawiyah is ‘absolutely under our control,’ government spokesman Moussa Ibrahim told reporters in Tripoli. ‘A very small group of rebels tried to move into the south of Zawiyah but they were stopped easily because of our armed forces,’ he said.
Rebel fighters returning south to Bir al-Ghanam from Zawiyah yesterday told Reuters the rebel force was in the city centre but not in complete control.
Zawiyah is the home town of many of the rebels battling on the western front and has staged two uprisings against Gaddafi since the nationwide revolt broke out in February.