Those killed in the suicide attack include a senior civil servant, officials say. Twenty-one other people were wounded in the attack claimed by Daesh.
Suicide attackers stormed the Libyan foreign ministry in the capital Tripoli on Tuesday, killing at least three people including a senior civil servant, the authorities said.
Twenty-one other people were wounded in what authorities said was a suicide attack carried out by "terrorists".
Daesh claimed the attack in an announcement on Amaq news agency.
A car bomb exploded near the ministry, prompting security forces to rush to the scene, said special forces spokesman Tarak al Dawass.
A suicide bomber then blew himself up on the second floor of the building while a second attacker died when a suitcase he was carrying exploded, he said.
A third assailant, who was unarmed and wearing a bulletproof vest, was killed by security forces outside, Dawass added.
Foreign Minister Tahar Siala said one of the dead was senior diplomat Ibrahim al Shaibi who headed a department in his ministry.
Plumes of smoke were seen rising from the building as ambulances, paramedics and security forces gathered outside.
Libya has been a haven for militants since 2011 when dictator Moammar Gadhafi was toppled in the aftermath of a NATO intervention that followed an uprising in the country.
The country is now split between rival governments, each backed by an array of local militias, some of which are influenced by foreign powers.