BIR SHAEB, Libya – Libyan rebels fought their way into the strategic city of Zawiya west of Tripoli on Saturday in their most significant advance in months, battling snipers on rooftops and heavy shelling from Moammar Gadhafi’s forces holding the city.

Zawiya, 30 miles from the capital, is a key target for rebels waging a new offensive launched from the mountains in the far west of Libya, an attempt to break the deadlock in combat between the two sides that has held for months in the center and east of the country.

A credible threat from the rebels in the west could strain Gadhafi’s troops, which have been hammered for months by NATO airstrikes. Defending Zawiya is key for the regime but could require bringing in better trained forces who are currently ensuring its hold over its Tripoli stronghold or fighting rebels on fronts further east.

A group of about 200 exuberant rebel fighters, advancing from the south, reached a bridge on Zawiya’s southwestern outskirts, and some rebels pushed farther into the city’s central main square. They tore down the green flag of Gadhafi’s regime from a mosque minaret and put up two rebel flags. An Associated Press reporter traveling with the rebels saw hundreds of residents rush into the streets, greeting the fighters piled into the backs of pickup trucks with chants of “God is great.”

Gadhafi’s forces then counterattacked with a barrage of heavy weapons, and the loud crackle of gunfire could be heard as rebels and government troops battled.

Regime snipers were firing down from rooftops on the rebels, said one resident, Abdel-Basset Abu Riyak. He said Gadhafi’s forces were holed up in several pockets in the city and that there were reports of reinforcements coming from Tripoli.

Rebel spokesman Jumma Ibrahim claimed that the opposition’s fighters controlled most of Zawiya by nightfall.