Colonel Fethallah al-Gaziri, the newly appointed chief of military intelligence in Benghazi, has been shot dead during a visit to his family in the eastern Libyan city of Derna.
A Libyan security official, speaking to the AFP news agency anonymously, said on Friday that "unknown assailants opened fire at Colonel Fethallah al-Gaziri... and killed him."
The official said Gaziri was in Derna for the marriage of a niece. His bullet-riddled body was taken to Derna hospital.
No group immediately claimed responsibility for Gaziri's killing.
Libya has witnessed a string of assassinations and bombings since former Libyan leader Muammar Gaddafi was toppled in 2011. In most cases, the government has been unable to identify the assailants.
Derna is known as a stronghold of Ansar al-Sharia, a hardline group suspected suspected of September 11, 2012, attack on the US consulate in Benghazi that killed the US ambassador Chris Stevens and three other Americans.
Much of recent violence and lawlessness in Libya has been blamed on heavily armed militias with roots in the 2011 war. They have undermined successive transitional governments and parliament, but the government also relies on many of them to provide security in the absence of a functioning police force.