Unknown gunmen have attacked a military post south-east of Tripoli, killing 15 soldiers, according to Libya's official news agency.
A military official said that gunmen in vehicles topped with machine guns attacked a checkpoint of the Infantry Second Brigade in the Wishtatah area.
"The ambush happened on the road between Bani Walid and the town of Tarhuna, where the army had a checkpoint. They came under heavy gunfire. Between 12 and 15 soldiers were killed," said Ali Sheikhi, a spokesman for the army joint chiefs of staff.
Another five soldiers are reported to have been wounded.
The Tarhuna hospital said it received 15 dead bodies and five wounded. Four were transferred to Sabaia hospital for further treatment.
The head of the Tarhuna hospital called for the Ministry of Health to assist with medical support.
The agency also said the road linking Bani Walid and Tarhuna has been closed.
Libya has recently been hit by a wave of attacks targeting military officers, activists, judges and security agents.
Two years after Muammar Gaddafi was overthrown and killed in a civil war, the north African country's fragile central government is struggling to control rival militias competing for influence in the aftermath of the conflict.
Officials did not say who might be responsible for the ambush.
However, clan and tribal rivalries, as well as the number of Islamist groups, have increased and taken control because of a weak central government, with Libya's armed forces failing to maintain order.