Islamic State claimed responsibility for a gun attack on a checkpoint east of the Libyan capital Tripoli earlier this week, the group's Amaq news agency said on Saturday.
Thursday's attack took place between the towns of Zliten and Khoms on the coastal road leading from Tripoli to the port city of Misrata, an area in which members of the militant group are known to be operating, according to the Zliten mayor.
Amaq said "seven Libyan road security personnel were killed" in the attack by Islamic State fighters, while around 10 more were wounded. It provided no evidence.
A local official and a resident on Thursday said at least four people had been killed in the attack, among them security personnel.
Libya has seen occasional attacks by militants who have benefited from the turmoil that followed a Nato-backed uprising in 2011.
Islamic State has said it was behind a deadly attack by gunmen on the offices of the electoral commission in Tripoli in May and an attack on a court complex in Misrata last year.
Local forces drove the militant group from its former stronghold in Sirte, southeast of Misrata, in 2016, but Libyan and Western officials say militants have sought to regroup through mobile desert units and sleeper cells in northern towns.
The United Nations is leading efforts to prepare for national elections in Libya, which it hopes will reunify rival factions based in Tripoli and the east of the country.