Gunmen opened fire early Sunday at the local guards of the South Korean Embassy in the Libyan capital, killing one of them as well as a civilian who was in the area, a Libyan security official said.

The South Korean Foreign Ministry said in a statement that no embassy officials were killed or wounded in the attack. It said the gunmen fired nearly 40 rounds with a machine gun.

A South Korean Foreign Ministry official said the attack took place soon after midnight, so the embassy was empty at the time. Three South Korean embassy officials were staying at the official residence, which is in the same compound. They remained in the residence Sunday, the official said, adding that they include two diplomats but not the ambassador. The official requested anonymity, citing department rules.

The head of diplomatic security in Libya's Tripoli-based Interior Ministry, Mabrouk Abu-Zaheer, told the Libyan news agency LANA that the gunmen targeted the security guards of the embassy early Sunday. He said another guard was wounded and the attackers fled.

Supporters of the Islamic State group's affiliate in Tripoli claimed responsibility for the attack on Twitter later Sunday.

Militant groups operate freely in Libya, which is torn between a militia-backed government in Tripoli and an internationally recognized government in the east.