The bloodshed signaled an escalation in efforts by both sides to break the deadlock that has gripped Libya's 18-day upheaval, which has lasted longer than the Egyptian revolt that led to the ouster of President Hosni Mubarak and inspired a wave of protests across the region.
So far, Gadhafi has had little success in taking back territory, with several rebel cities repelling assaults and the entire eastern half of the country under rebel control. But the opposition forces have seemed unable to go on the offensive to march on pro-Gadhafi areas.
Meanwhile, in Tripoli - Gadhafi's most important bastion - his loyalists have waged a campaign of terror to ensure that protesters do not rise up in significant numbers.
Friday's assault on the rebel city of Zawiya, about 30 miles west of Tripoli, appeared to be the strongest yet by Gadhafi's forces after repeated earlier forays against it were beaten back.
In the morning, troops from the elite Khamis Brigade - named after the Gadhafi son who commands it - bombarded the city's western edges with mortar shells, heavy machine guns, tanks and anti-aircraft weapons, several residents said. By the evening, another brigade had opened a front on the eastern side. Armed Zawiya citizens backed by allied army units were fighting back.
The commander of the rebel forces - Col. Hussein Darbouk - was killed by fire from an anti-aircraft gun, said Alaa al-Zawi, an activist in the city. Darbouk was a colonel in Gadhafi's army who defected along with other troops in Zawiya early in the uprising.
A witness in Zawiya's hospital said at least 18 people were killed and 120 wounded. Libyan state TV reported the attackers had retaken the city. But al-Zawi, the witness and other residents said it remained in rebel hands, with skirmishes continuing after nightfall.
A doctor on the scene said pro-Gadhafi fighters would not allow medics to treat the injured, opened fire on ambulances trying to assist and hauled away the bodies of some of the dead in an apparent effort to keep death toll reports low. The gunmen killed a wounded rebel with three shots as a medic tried to pull him to safety, then even threatened to shoot the medic, the doctor said.
The doctor and witnesses spoke on condition of anonymity for fear of retaliation.
The day's other fighting took place at Ras Lanouf, a small oil port 380 miles (620 kilometers) east of Tripoli, just outside the long swath of eastern Libya controlled by the opposition.
Rebels attacked Ras Lanouf on Friday afternoon, feeling flush with victory after repelling Gadhafi forces who attacked them days earlier at Brega, a larger oil facility just to the east. Fighters armed with Kalashnikovs and heavy machine guns were seen streaming in pickup trucks and other vehicles from Brega heading in the direction of Ras Lanouf.
They battled about 3,000 pro-Gadhafi troops, mainly around the facility's airstrip, said a resident of the town. She reported heavy explosions starting around 4 p.m. As night fell, the explosions eased, she said, but it was not clear who was in control of the complex, which includes a port and storage facilities for crude coming from fields in the deserts to the south.
Ahmed al-Zwei, a member of the post-uprising town committee in nearby Ajdabiya, said the rebels were in control of the Ras Lanouf airstrip and the oil and gas facilities, and the regime forces had returned to their base at Sirte, a Gadhafi stronghold.
At least two dead and 16 wounded were taken to the hospital at nearby Ajdabiya, although that did not include the toll from other hospitals in the area. Al-Zwei, however, said the Gadhafi forces had killed 20 guards from the two facilities. The death toll couldn't immediately be confirmed.
To the northeast, hospital officials said at least 17 people were killed in an explosion at an ammunition storage facility at a military base about 20 miles (32 kilometers) from the rebel stronghold of Benghazi.
The blast destroyed one warehouse in the base and damaged a second, according to an ambulance driver who said he recovered body parts from the scene. The driver spoke on condition of anonymity because he was not authorized to talk to the media.
"There were so many people killed. I can't describe it," said a resident of Benghazi who gave his name as Abdullah and whose voice was filled with emotion.
Dr. Habib al-Obeidi in Benghazi's al-Jalaa hospital says the blast also hit a residential area. Witnesses on the scene, said secondary explosions destroyed two firetrucks.
The cause of the blast was unclear. Al-Obeidi says it apparently was triggered when people went into the storage facility to collect weapons, but others blamed pro-Gadhafi saboteurs.
The fall of other parts of the country has made control of Tripoli crucial for Gahdafi. His loyalists have taken fierce action to ensure protesters cannot rise up and overwhelm the city as they have in other places.
Last week, Friday marches were met by gunfire from militiamen shooting into crowds, killing a still undetermined number. Since then, pro-Gadhafi forces have carried out a wave of arrests against suspected demonstrators, snatching some from their homes in nighttime raids and terrorizing even the most restive neighborhoods.
The fear seemed to have had an impact, and some protests planned Friday in other parts of the capital didn't get off the ground. One resident said he went to prayers at a downtown mosque and found police officers standing outside to ensure no one marched. After prayers, worshippers dispersed without protests.
Some 400 protesters marched out of the Murad Agha mosque after noon prayers in the eastern Tripoli district of Tajoura, chanting, "The people want to bring the regime down!" and waved the red, black and green flag of Libya's pre-Gadhafi monarchy, which has become the banner of the uprising.
Pro-Gadhafi forces quickly moved in. They fired volleys of tear gas and - when the marchers continued - opened fire with live ammunition, according to witnesses.
It was not clear if they fired at the crowd or into the air, but the protesters scattered, many of them taking refuge back in the mosque, according to an Associated Press reporter at the scene. A doctor said several people were wounded and taken to a hospital.
"All these people are threatened with death," said a 35-year-old among the Tajoura protesters Friday. "We have no education, no economy, no infrastructure. ... We want nothing but the end of the regime. We were born free but he is suppressing us." He said he had recently had kidney surgery, but "look at me, still I went out with the people because we are oppressed people."
"I am not afraid," said another man in the march. "We want to show the world that we are not afraid."
Thousands of Gadhafi supporters later packed into the capital's central Green Square, waving green flags and pictures of the Libyan leader in a counterdemonstration complete with fireworks.
Armed men dressed in blue formed a security cordon around mosques in Tripoli while helicopters buzzed overhead.
Before prayers, some 1,500 worshippers inside the Murad Agha mosque debated what to do.
At one point, they decided to hold a sit-in inside the mosque to avoid coming under gunfire by stepping outside. In the mosque's courtyard, they burned a copy of the Green Book, Gadhafi's political manifesto, as well as the green flag of Gadhafi's Libya.
At the same time, young men from the neighborhood transformed a nearby square, tearing down posters of the Libyan leader and replacing them with the flags. They spray-painted walls with graffiti reading, "Down with Gadhafi" and "Tajoura will dig your grave."
In the end, the 400 worshippers in the mosque decided to march.
Internet services, which have been spotty throughout Libya's upheaval, appeared to be halted completely in Tripoli on Friday before the protests. Renesys Corp., a Manchester, New Hampshire, company that maps the pathways of the Internet, said it wasn't able to reach any of the websites it tried to access inside Libya. Google's transparency report, which shows traffic to the company's sites from various countries, also showed that Internet traffic in Libya had fallen to zero.
Libyan authorities briefly barred many foreign journalists from leaving their Tripoli hotel, claiming it was for their protection because they had information "al-Qaida elements" planned to open fire on police to spark clashes. They later allowed them to go out.
Several hours before prayers, security forces began taking up positions. In Tajoura, police set up two checkpoints on the main highway to downtown. They stopped cars to search them, check IDs and question them.
El Deeb reported from Cairo. Associated Press writers Paul Schemm in Benghazi, Libya; Bassem Mroue in Cairo and Barbara Ortutay in New York contributed to this report.