The attackers rode vehicles mounted with machine guns, a military official said.
The highway between the towns of Tarhouna and Bani Walid, on which the post was located, was closed immediately after the attack.
The official said the attack took place in the Wishtata area, some 40 miles (60km) from the entrance to Bani Walid. The town was one of the last strongholds for supporters of Muammar Gaddafi in the country's 2011 civil war, and was besieged again by pro-government militias last year.
Fifteen soldiers died in the attack, and five were injured, a health official said. One wounded soldier later died at a nearby hospital, the official said, adding that one more soldier remained in a critical condition.
Libya has been hit by a months-long wave of attacks targeting military officers, activists, judges and security agents.