Islamists killed at least 22 soldiers on Thursday after a surprise attack in which they used speedboats in a failed bid to seize some of Libya's main oil terminals, officials said.
The fighting in the oil-rich region came as pro-government forces lost ground to Islamist militias in the eastern city of Benghazi, where jihadists beheaded six people and killed 14 others, military officials said.
The militiamen belonging to the Fajr Libya, or Libya Dawn, launched the attack on Al-Sidra port by firing rockets from speedboats, setting an oil tank on fire, security sources said.
Soldiers damaged three of the vessels before clashes in which the militants were eventually repelled.
"These speedboats had fired several rockets at the terminals of Ras Lanuf and Al-Sidra and one of them hit a tank south of Al-Sidra port which then caught fire," said Ali al-Hassi, security spokesman for the region.
Al-Sidra is in the "oil crescent" region that has been the scene of recent fighting between government forces and Fajr Libya.
The latest clashes pushed oil prices higher in Asia on Friday, with US benchmark West Texas Intermediate for February delivery rising 28 cents to $56.12, while Brent for February gained 13 cents to $60.37.
Witnesses said the attack was launched overnight, and reported seeing smoke from the burning oil tank.
Military and medical sources said 18 soldiers and a Fajr Libya fighter were killed in Sirte, and another four soldiers were slain in Al-Sidra.
Most of the dead soldiers belonged to the 136th battalion responsible for monitoring a power plant west of Sirte, the sources said.
- Oil production hit -
Signup to our newsletter and follow us on Facebook and Twitter!
Since the clashes erupted on December 13, the country's oil production has dropped to nearly 350,000 barrels per day compared with 800,000 previously, according to industry experts.
"The armed forces on Thursday repelled an attack in which the Fajr Libya militia tried to seize the Al-Sidra oil terminal," said Hassi.
A medical source at Ibn Sina hospital in Sirte said earlier that the facility had received 18 bodies from the fighting.
The 136th battalion is affiliated with the military, and most its fighters are from a tribe loyal to former general Khalifa Haftar.
A military official said Haftar's forces and pro-government troops had lost several positions in Benghazi to Islamist militias in the past 24 hours.
"Islamist gunmen seized large parts of Al-Lithi in south-central Benghazi, setting fire to 45 homes of people linked to Haftar and pro-government forces," the official said.
The official, who declined to be named, said six people were beheaded and 14 others killed in the attacks.
Haftar's forces have been fighting alongside forces from the internationally recognised government of Prime Minister Abdullah al-Thani to overrun Islamists from Benghazi.
In other violence on Thursday, three Fajr Libya men were killed in a raid in Tripoli, which Islamists seized in the summer after fierce fighting with nationalist forces.
On December 16, a warplane belonging to Fajr Libya fired missiles at a sector to the west of Al-Sidra, in the first such raid in the energy-rich region.
More than three years after dictator Moamer Kadhafi was toppled and killed in a NATO-backed revolt, Libya is still awash with weapons and powerful militias, and has rival parliaments as well as governments.