Moammar Gadhafi loyalists broke through rebel lines at an opposition-held city that is closest to the Libyan capital on Saturday, while anti-government forces celebrated the capture of a key oil port from the regime on the eastern coast.
The contrasting fortunes of the two warring sides suggest that the conflict in Libya is veering toward a lengthy civil war, with the government fighting fiercely to maintain its hold in Tripoli and surrounding areas and the rebels pushing their front westward from their eastern stronghold.
Gadhafi, who has led the country virtually unchecked for four decades, has unleashed a violent crackdown against those seeking his ouster, drawing international condemnation and sanctions.
Hundreds have been killed, perhaps more, putting pressure on the international community to do more to stop the crackdown on protests that began on Feb. 15, inspired by successful uprisings in Egypt and Tunisia, its neighbors to the east and west respectively.
President Barack Obama has insisted that Gadhafi must leave and said his administration was considering a full range of options, including the imposition of a "no-fly" zone over Libya.
So far, Gadhafi has had little success in taking back territory, with the entire eastern half of the country and some cities near the capital under rebel control. But the opposition forces have had limited success in marching on pro-Gadhafi areas, leading to a standoff that could last for weeks and maybe months, with neither side mustering enough military power to decisively defeat the other.
Saturday's assault on Zawiya, a city of some 200,000 people just 30 miles (50 kilometers) west of Tripoli, began with a surprise dawn attack by pro-Gadhafi forces firing mortar shells and machine guns.
Witnesses, who spoke to the Associated Press by telephone with the rattle of gunfire and explosions heard in the background, said the shelling damaged government buildings and homes. The fighting sparked several fires, sending a cloud of heavy black smoke over the city, and witnesses said snipers were shooting at anybody on the streets, including residents who ventured onto balconies.
Initially, the rebels retreated to positions deeper in the city before they launched a counter offensive in which they regained some of the lost territory, according to three residents and activists, who spoke on condition of anonymity for fear of reprisals.
By mid-afternoon, the rebels had reoccupied the city's central Martrys' Square while the pro-regime forces regrouped on the city's fringes, sealing off the city's entry and exit routes, the witnesses said, adding more fighting was expected later in the day.
"We will fight them on the streets and will never give up so long as Gadhafi is still in power," said one of the rebel fighters, who also declined to be identified for the same reason.
The anti-Gadhafi rebels fared better elsewhere, capturing the key oil port of Ras Lanouf from regime forces on Friday night, their first military victory in a potentially long and arduous westward march from the east of the country to Tripoli.
Witnesses said Ras Lanouf, about 90 miles (140 kilometers) east of pro-Gadhafi Sirte, fell to rebel hands on Friday night after a fierce battle with pro-regime forces who later fled.
An Associated Press reporter who arrived in Ras Lanouf Saturday morning saw Libya's red, black and green pre-Gadhafi monarchy flag, which has been adopted by the rebels, hoisted over the town's oil facilities.
One of the rebels, Ahmed al-Zawi, said the battle was won after Ras Lanouf residents joined the rebels.
"We won the battle when the people joined us," said al-Zawi, who participated in the fighting. He said 12 rebels were killed in the fighting, in which rocket-propelled grenades and anti-aircraft guns were used.
Officials at a hospital in the nearby city of Ajdabiya, however, said only five rebels were killed and 31 wounded in the attack. The discrepancy in the figures could not immediately be explained.
"They just follow orders. After a little bit of fighting, they run away," said another rebel at Ras Lanouf, Borawi Saleh, an 11-year veteran of the army who is now an oil company employee.
The march on Sirte, said al-Zawi, would start after the rebels regroup and reorganize.
In the rebel-held east of the country, meanwhile, a large arms and ammunition depot outside Benghazi, Libya's second largest city, blew up Friday in a massive explosion that completely destroyed an area three times the size of a soccer field.
Ambulance drivers told AP Television News that at least 26 people had been killed in the blast, which flattened entire buildings, cars and trees. It also deprived the rebels of arms and ammunition needed to fight their way westward toward Sirte on the Mediterranean coast.
It was not immediately clear how the depot blew up, but suspicion immediately fell on Gadhafi agents.
Schemm reported from Ras Lanouf, Libya. Associated Press writer Hamza Hendawi contributed to this report from Cairo.