ZAWIYA, Libya - Dozens of opposition fighters surrounded Libya's last functioning oil refinery Wednesday and laid siege to about 100 government troops, part of a push which brought them closer to seizing this strategic western city.

A rebel victory in Zawiya could be a turning point in the six-month-old war and leave Moammar Gadhafi nearly cornered in his increasingly isolated stronghold of Tripoli, the capital, just 50 kilometres to the east along the Mediterranean coast.

Rebel fighters are now closing in on the capital from the west and the south, while NATO controls the seas to the north. The opposition is in control of most of the eastern half of the country and has declared Benghazi, 1,000 kilometres east of Tripoli, as its de facto capital.

Wednesday's fighting focused around the sprawling refinery complex on the western outskirts of Zawiya, a city of 200,000. The rebels, who began their assault on the refinery a day earlier, took control of the facility's three-story administration building, tearing down the Gadhafi regime's green flag that flew over the grounds.

Desperate Gadhafi troops cut off from the main government forces took cover in a residential compound and closed the gates to prevent workers from fleeing, rebels said. The troops barricaded themselves in and positioned snipers on rooftops. An Associated Press photographer inside the refinery with rebel troops heard occasional bursts of gunfire.

An oil engineer in the compound told the AP that about 100 Gadhafi soldiers remained inside late Wednesday afternoon. At least several dozen rebel fighters were also in the area. Arusi said his forces controlled parts of the complex.

The Libyan rebels made a dramatic advance on Saturday out of their bases in the western mountains near Tunisia into Zawiya on the Mediterranean coast. Since then, they have taken control of 70 per cent of the city, rebel commanders say, and have been slowly gaining ground in fierce battles with Gadhafi's forces.

The clashes at the refinery began on Tuesday, then opposition fighters pulled out at nightfall and made a new push after daybreak, Arusi said.

Arusi said rebels wanted to take the refinery undamaged, and have been negotiating with Gadhafi soldiers inside the refinery since 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.

The remaining Gadhafi loyalists closed the gate of the residential compound for refinery workers and their families. It was unclear how many people were living there. Many of the workers were evacuated early in the civil war, which began in mid-February.

"If (the civilians) leave, we can deal with Gadhafi's guys with full force," Arusi said. "So Gadhafi'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.

A rebel field commander in Zawiya, Osama Arusi, said the clashes at the refinery shut down an oil pipeline to Tripoli, where a third of Libya's 6 million people live.

"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."

Neither a pipeline shutdown nor a capture of the 120,000 barrel-per-day refinery in Zawiya would have a major impact on Gadhafi's ability to secure fuel, analysts said.

The flow of crude to the refinery from fields in the southwest of Libya had largely halted since midsummer. 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. At any rate, Zawiya produces mostly fuel oil, not gasoline, which Gadhafi had trucked 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 Gadhafi to get the petrol he needs" from Tunisia and Algeria.

In fighting elsewhere in the west, more than 45 wounded rebel fighters arrived in Tunisia for medical care over the past 24 hours through the Zintan border crossing, Tunisia's official TAP news agency reported.

Outside the rebel-held city of Misrata east of Tripoli, opposition fighters said they captured the town of Haysha, located halfway between Misrata and Gadhafi's hometown of Sirte on the Mediterranean coast. Haysha was used by Gadhafi forces as a base to fire rockets on Misrata.

On the eastern front of the civil war, hundreds of miles from Zawiya around the coastal town of Brega, rebels clashed with Gadhafi troops for control of the town's oil refinery. The front lines have swept through Brega several times, and the oil facility there has not been operating for months.

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

He said that at least 18 rebels had been killed and 74 wounded in fighting Tuesday.

Rebel fighter Moussa Ahmaid, who was escorting the wounded rebels to the hospital, said the fighting was mainly on 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."