The militiamen belonging to the Fajr Libya, or Libya Dawn, launched the attack on the port of Al-Sidra by firing rockets from speedboats, setting an oil tank on fire, security sources said.
Soldiers damaged three of the vessels before clashes in which at least 19 of them were killed, they said, adding 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.
A military source said 19 soldiers were killed in the region, and that the oil tank struck by a rocket was still burning in the Al-Sidra oil terminal.
Also Read
Al-Sidra is located in the region known as the "oil crescent" that has been the scene of recent fighting between government forces and Fajr Libya.
Since the clashes erupted on December 13, oil production in the country has dropped to nearly 350,000 barrels per day compared with 800,000 previously, according to industry experts
A medical source at Ibn Sina hospital in Sirte said the facility received 18 bodies from the fighting.
The number of casualties among the Islamist militants was unknown.
The 136th battalion is affiliated with the military. Most its fighters are from a tribe loyal to former general Khalifa Haftar.
Haftar's forces have been fighting alongside forces from the internationally recognised government of Prime Minister Abdullah al-Thani against Islamist militants who have seized control of cities including Tripoli.
On December 16, a warplane belonging to Fajr Libya fired missiles at a sector to the west of Al-Sidra, Hassi said at the time, in the first such raid in the energy-rich region.
Islamists have seized Tripoli and Benghazi in the east, and forces loyal to Thani are fighting to regain control of the cities.