A defiant Moamer Kadhafi vowed to fight until victory as his forces launched surprise fightbacks on three fronts on Monday, and as Libya's interim government won recognition from China.
The ferocious counterattacks on a Ras Lanuf oil refinery, near Kadhafi's hometown of Sirte, and at Bani Walid near Tripoli came as a US official said Niger was ready to detain one of the elusive leader's sons, Saadi, after he fled over the border.
"It is not possible to give Libya to the colonists again," and "all that remains for us is the struggle until victory and the defeat of the coup," Kadhafi said in a statement read out on Syria-based Arrai Oruba television.
Kadhafi has gone underground since being ousted from Tripoli late last month, and Libya's new interim leader, Mustafa Abdel Jalil, received a hero's welcome in the city's main square.
A crowd of thousands celebrated victory against Kadhafi's in Martyrs' Square, two days after Abdel Jalil, the head of the National Transitional Council (NTC), arrived in Tripoli from the former rebels' eastern stronghold of Benghazi.
Jalil told the crowd Islam will be the main source of legislation in post-Kadhafi Libya.
"We will not accept any extremist ideology, on the right or the left. We are a Muslim people, for a moderate Islam, and we will stay on this road," he said.
NATO vowed no let-up in its bombing campaign against Kadhafi's remaining strongholds, which also include the southern oases of Waddan and Sabha, as long as they pose a threat.
China, which opposed the NATO air strikes which began in late March, became the latest country to recognise the NTC as Libya's government, the state-run Xinhua news agency reported.
And Washington sent an advance team of four troops to help its officials reopen the US embassy in Tripoli.
But forces loyal to the fugitive Kadhafi sprang a surprise deep behind enemy lines, killing at least 12 NTC soldiers in a raid on the refinery near Ras Lanuf on the central coast.
"So far, we have a figure of 12 dead in the ranks of the revolutionaries" guarding the key plant, military spokesman Mohammed Zawawi told AFP.
"A group (of loyalists) travelling in five vehicles tried to enter the refinery but were unable to," he said.
The oil infrastructure along the Mediterranean coast between Sidra and Brega was a key battleground of the seven-month uprising against Kadhafi, and the front line between the mainly rebel-held east and mainly government-held west went back and forth several times.
But since Tripoli's fall, NTC forces have advanced dozens of kilometres (miles) west towards Sirte, which remains in Kadhafi's hands, and have moved to secure the vital oil infrastructure on which its post-war reconstruction plans depend.
Southeast of Tripoli, civilians poured out of the desert town of Bani Walid after intense fighting on Sunday between Kadhafi loyalists in the oasis and encircling new regime troops.
Many more remained trapped inside the town, 180 kilometres (110 miles) from the capital, for want of fuel for their vehicles, those fleeing said.
Signup to our newsletter and follow us on Facebook and Twitter!
"Families are scared to death by this war," said Mohammed Suleiman as he passed through a checkpoint with 10 relatives crammed into the back of his white BMW.
West of Sirte, an NTC commander said his forces had met strong resistance as they advanced towards the city on Sunday.
"We advanced yesterday to a place called Checkpoint 50," 50 kilometres from Sirte, said field commander Umran al-Awaib.
"There was strong resistance -- we came under fire from a lot of Grads (rockets)."
Libya's military said people in central Sirte staged an uprising in which four people were killed.
Revolutionaries "were rising up today inside Sirte city... there are four martyrs," the Misrata Military Council said, although the report could not be verified.
The unexpected counteroffensive by Kadhafi loyalists came despite the flight to neighbouring Niger of 32 members of his inner circle during the past 10 days.
"A total of 32 people are now here, including one of (Kadhafi's) sons, Saadi, as well as three generals," Niger's Prime Minister Brigi Rafini said.
He added that they crossed the border in four separate groups and had been taken in for "humanitarian reasons".
The most recent arrivals included Saadi, the third of Kadhafi's seven sons and known as a playboy, and eight of the fallen despot's other close associates, Rafini added.
Later, US State Department spokeswoman Victoria Nuland said, however, that Niger was preparing to detain Saadi.
"We have confirmed with the government of Niger that Saadi crossed over, that they are either in the process or have already brought him to the capital of Niamey and intend to detain him," she said.
Moamer Kadhafi, his most prominent son Seif al-Islam and his intelligence chief Abdullah al-Senussi are all wanted by the International Criminal Court for alleged crimes against humanity.
But Rafini said "as far as we are aware, none of the 32 in Niger are being sought on an arrest warrant or being pursued by international justice."
On the diplomatic front, China formally recognised the NTC as Libya's government after weeks of holding back.
"China respects the choice of the Libyan people and attaches great importance to the status and role of the NTC, and has kept in close contact with it," the state-run Xinhua news agency quoted foreign ministry spokesman Ma Zhaoxu as saying in a statement.
As the Pentagon said four troops were heading to Tripoli to help reopen the US embassy, officials said the move does not represent a policy shift by President Barack Obama, who has insisted there will be no US boots on the ground in Libya.
In its latest update, NATO said warplanes had hit 13 targets in and around Sirte, four around Waddan and one near Sabha.
NATO chief Anders Fogh Rasmussen said the strikes would go on until the threat to civilians had been eliminated.