Updated

Heavy clashes broke out Wednesday between rebels and Muammar al-Qaddafi loyalists fighting for control of Libya's only functioning oil refinery in the western city of Zawiya, as the opposition tried to cut off fuel supplies to the regime's stronghold of Tripoli.

A rebel field commander in Zawiya, Osama Arusi, said the fighting has shut down an oil pipeline to the capital, where a third of Libya's six million people live. The rebels have surrounded the refinery, which supplies oil and gas to the capital.

"The pipeline from Zawiya to Tripoli has been switched off," Arusi told The Associated Press. "The man who is responsible for switching the pipeline off said it is not working."

The Libyan rebels made a dramatic advance on Saturday out of their bases in the western mountains near Tunisia into Zawiya, just 30 miles of Tripoli. They took control of parts of the city of 200,000, and have since been slowly gaining ground in fierce battles with Qaddafi's forces for days.

The rebel advance is tightening the noose around Tripoli. The fighters are closing in on the capital from the west and the south, while NATO controls the seas off the north of Tripoli, which sits on the Mediterranean coast. Hundreds of miles away from the capital, the opposition is in control of most of the eastern half of the country, and has a transitional leadership council in the rebel de facto capital of Benghazi.

More On This...

The clashes at the refinery began on Tuesday, then opposition fighters pulled out at nightfall and made a new push in daylight, Arusi said. An Associated Press photographer entered the refinery with the rebels and heard sniper fire.

An oil engineer in the compound told the AP that about 100 Qaddafi soldiers remained inside. At least several dozen rebel forces are in the area also. Arusi said his forces control parts of the complex and confirmed that some regime troops and civilian workers remain inside. The refinery is located west of the city on the Mediterranean coast.

Arusi said rebels began negotiating with Qaddafi soldiers inside the refinery after entering Zawiya on Saturday. He said on Tuesday morning, some of the regime fighters, all locals, surrendered to the rebels after several days of negotiations.

Some of the remaining Qaddafi loyalists have closed the gate of the residential compound for refinery workers and their families and they control it. But many of the workers were evacuated early in the civil war that began in mid-February.

"If (the civilians) leave, we can deal with Qaddafi's guys with full force," Arusi said "So Qaddafi's guys don't want them to leave. They keep them as protection."

About half a mile south of the refinery, an AP reporter saw two cars carrying civilians driving away from the refinery on an otherwise deserted road. Meanwhile, three pickup trucks loaded with fighters sped toward the refinery along the same road, to reinforce the troops.

The capture of the 120,000 barrel per day refinery in Zawiya is more a symbolic coup for the rebels, without major impact on Qaddafi's ability to secure fuel, analysts said.

The flow of crude to the refinery from fields in the southwest of Libya had largely been halted since midsummer and the refinery was believed to be running at about one-third of its normal capacity, drawing mainly on crude oil that was in its storage tanks. But Zawiya mostly produced fuel oil, versus gasoline, which Qaddafi was trucking in mainly from Tunisia and, to a lesser extent, Algeria.

"In that sense, it's more significant that they (the rebels) have got control of the roads than the refinery," said John Hamilton, a Libya energy expert with Cross-Border Information and a contributing editor of Africa Energy. "Strategically, that's a more important gain for the rebels. Having control of the roads makes it much harder for Qaddafi to get the petrol he needs" from Tunisia and Algeria.

On a second front in the civil war, hundreds of miles from Zawiya around the coastal town of Brega in the east, rebels clashed with Qaddafi troops for control of the town's refinery.

A rebel doctor in Brega, Mohammed Idris, said the field hospital in Brega was overwhelmed by the number of casualties and many wounded were sent to Benghazi for treatment.

He said that as of Tuesday night, 18 rebels had been killed and 74 injured.

Rebel fighter Moussa Ahmaid, who was escorting the wounded rebels to the hospital, said the fighting is mainly no the southern side of Brega.

"We are using light hand held weapons and mortars," he told the AP. "Most of our casualties are from sniper fire or shrapnel from shelling."