Sixteen Libyan soldiers were killed when unidentified gunmen attacked an army checkpoint between two towns southeast of Tripoli on Saturday, a military spokesman said.
"An army checkpoint in Al-Malti region between Tarhuna and Bani Walid was attacked at dawn on Saturday by an unknown group. Fifteen soldiers were killed and four others wounded," Ali Sheikhi said.
The military high command later said that one of the wounded had died from his injuries.
Libyan news agency Lana gave a casualty toll of 15 dead and five wounded, adding that the road between Tarhuna and Bani Walid, a former bastion of support for Libya's toppled leader Moamer Kadhafi, had been closed to traffic.
Signup to our newsletter and follow us on Facebook and Twitter!
It said the dead and wounded were taken to a hospital in Tarhuna, 80 kilometres (50 miles) southeast of the capital.
A government statement declared "three days of national mourning because of the deaths of 16 soldiers killed by criminals and assassins who daily target Libya and her sons."
The high command, in a separate statement, called the attackers "outlaws and enemies of the Libyan people who want to destabilise security and sow dissent."
It pledged to "hunt them down and bring them to justice."
Members of Libya's security forces, being trained to form a new army and police force in the wake of the 2011 revolt which ousted Kadhafi, are often the target of attacks, especially in the east.
With the authorities struggling to establish new security forces, many militia groups made up of former rebels who fought Kadhafi two years ago have refused to give up their weapons and effectively control parts of the country.