TRIPOLI Muammar Gaddafi vowed to "crush any enemy" on Friday, addressing a crowd of supporters in Tripoli as Libya's popular uprising closed in around him.
"We will fight if they want," the 68-year-old leader declared after a day of clashes all over the capital between security forces and crowds of protesters, which Gaddafi's opponents said had left some districts in their hands.
With eastern Libya already under opposition control after a week of unrest, protesters held the center of Zawiyah, west of the capital, a witness said, and laid makeshift defences to fend off government forces after successive fierce attacks.
The United States, whose calls for restraint have fallen on deaf ears, said it was preparing sanctions against Gaddafi and was not ruling out military action.
The U.N. Security Council also drew up sanctions including an arms embargo, travel bans and freezing top officials' assets, and threatened Libyan leaders with indictments for crimes against humanity.
But the international community has struggled to keep up with the pace of protests which have already swept away the authoritarian rulers of Egypt and Tunisia this year.
Gaddafi's own people seemed close to forcing him from power.
A string of other towns were reported to have fallen to the opposition, although Gaddafi retained the defiance he has often displayed against the West over more than four decades.
"Get ready to fight for Libya, get ready to fight for dignity, get ready to fight for petroleum!" he urged the crowd of thousands in Tripoli's central Green Square, threatening to open military arsenals to his supporters and tribesmen.
"We can crush any enemy. We can crush it with the people's will," he said, shouting and waving his fists.
FIGHTING IN TRIPOLI
Residents said parts of Tripoli, apparently the last major stronghold of the man who took over Libya in a 1969 coup, were already beyond his control.
"I think Tripoli is in uprising," said one man in the city center. "When you go to Green Square you find it full of Gaddafi supporters. In the other areas, they went out after Friday prayers and they are demonstrating against Gaddafi."
"In some areas it was contained and in some other areas they are ... firing in the air to try to disperse them."
Al Jazeera television said two people had been killed and several wounded by government forces in heavy shooting in several districts. Another channel, Al Arabiya, said seven people had been killed.
Protesters controlled some roads to the city so people from towns nearby could join the fight for the capital, a Libyan in Europe in contact with relatives in Tripoli told Reuters.
"They will try to march to Gaddafi's palace. I think there could well be a Ceausescu scenario," he said, referring to the shooting of Romanian communist dictator Nicolae Ceausescu and his wife by the army after a summary trial in December 1989.
A former ally of Gaddafi has said he would go down "like Hitler" after World War Two rather than surrender.
U.N. High Commissioner for Human Rights Navi Pillay said "thousands" may have been killed or injured by Gaddafi's forces in the uprising, and called for international intervention to protect civilians. One Libyan medical charity was quoted as saying 2,000 had died in Benghazi alone.
Washington, having evacuated Americans from Libya, said it was closing down its embassy. Gaddafi, once branded a "mad dog" for backing global militants, had recently found a cautious welcome in the West, which has sought access to its oil.
Witnesses in Zawiyah, an oil refining town on the main coastal highway 50 km (30 miles) west of Tripoli, fought off government forces on several nights, according to witnesses who fled across the Tunisian border at Ras Jdir.
"There are corpses everywhere ... It's a war in the true sense of the word," said Akila Jmaa, who crossed into Tunisia on Friday after traveling from the town.
Other reports say Libya's third biggest city, Misrata, 200 km (120 miles) east of Tripoli, was also under rebel control.
Gaddafi's son Saif al-Islam said his forces were holding back in Zawiyah and another western town, Misrata, and hoped to negotiate a peaceful outcome with the "terrorists" by Saturday.
He said earlier his family had no intention of leaving.
"We have plans A, B and C. Plan A is to live and die in Libya. Plan B is to live and die in Libya. Plan C is to live and die in Libya," he told Turkey's CNN Turk television.
A Tripoli resident who asked not to be identified told Reuters in an email that pro-Gaddafi forces had opened fire on hundreds of people in the Janzour district in western Tripoli who began a protest march after Friday prayers.
Hadar, a businessman who declined to give his full name, told Reuters by telephone: "I saw two men fall down and someone told me they were shot in the head."
Ali, another businessman who declined to give his full name, told Reuters by phone that he was standing with a crowd near a mosque on a road leading to Green Square.
"They just started shooting people. People are being killed by snipers but I don't know how many are dead," he said.
The World Food Program said first-hand accounts from people fleeing the violence indicated shortages of food, fuel and medical supplies, exacerbated by port closures.
Prosecutor-general Abdul-Rahman al-Abbar became the latest senior official to resign, and told al Arabiya he was joining the opposition. Libya's delegations to the Arab League and the United Nations in Geneva also switched sides.
State television said the government was raising wages and food subsidies and ordering special allowances for all families, a late bid to enrol the support of Libya's 6 million citizens.
Gaddafi's four decades of totalitarian rule have stifled any organized opposition or rival political structures, but in the east, ad hoc committees of lawyers, doctors, tribal elders and soldiers appeared to be filling the vacuum left by Gaddafi's government with some success.
There was little sign of the radical Islamists whom Gaddafi has accused of fomenting the unrest.
Instead, in Benghazi, the "Feb 17. coalition" was cleaning up, providing food, building defences, reassuring foreign oil firms and saying it believed in a united Libya.
Army and police in the eastern city of Adjabiya told Al Jazeera that they too had gone over to the opposition and a man back from the Western Mountains region about 150 km (90 miles) southwest of Tripoli said three towns there were also no longer under central control.
Libya supplies 2 percent of the world's oil, the bulk of it from wells and supply terminals in the east. Abdessalam Najib, a petroleum engineer at the Libyan company Agico and a member of the February 17 coalition, said the rebels controlled nearly all oilfields east of Ras Lanuf.
But industry sources told Reuters that crude oil shipments from Libya, the world's 12th-largest exporter, had all but stopped because of reduced production, a lack of staff at ports and security concerns. A company source at Ras Lanuf said operations there had shut down. [nLDE71O19F]
A Reuters reporter saw that the other main terminal, Marsa el Brega, was in rebel control, with soldiers securing the port.
Benchmark Brent oil futures were steady at around $112, after a Saudi assurance that it would replace any shortfall in Libyan output brought prices back from Thursday's peak of nearly $120.
The U.N. Security Council was expected to vote on the sanctions proposal next week, although Secretary General Ban Ki-moon called for quick action. "The hours and the days ahead will be decisive for Libyans," he said.
European diplomats said the European Union was likely to agree its own sanctions early next week.
But NATO Secretary General Anders Fogh Rasmussen said NATO members had not yet discussed trying to impose a no-fly zone to protect rebel-held areas from air attacks.
(Additional reporting by Alexander Dziadosz, Tom Pfeiffer and Mohammed Abbas in eastern Libya,, Ali Abdelatti in Cairo, Amena Bakr in Riyadh, Michael Georgy on the Tunisian border, Stephanie Nebehay and Robert Evans in Geneva; Writing by Kevin Liffey and Philippa Fletcher; Editing by Andrew Roche and Alastair Macdonald)