Unidentified gunmen fired shots at the South Korean embassy in Tripoli on Sunday killing two local security guards, a South Korean official in Seoul said.

The gunmen fired from a car at the embassy compound, killing two security officers who were Libyan government employees and wounding another, the South Korean foreign ministry official said, asking not to be identified.

The official said the embassy is staffed by two foreign service officials and one administrative staff member.

There was no confirmation of the identity of the gunmen, the official said. China's Xinhua news agency quoted a Libyan security official as saying the gunmen were affiliated with Islamic State in Iraq and Syria.

Libyan militants professing loyalty to Islamic State in Iraq and Syria have been blamed for several high-profile attacks this year involving foreigners, including an assault on a luxury Tripoli hotel and the beheading of 21 Egyptian Christians.

Libya is caught up in a conflict between two rival governments and armed forces who have attacked towns allied with opponents. But Islamist militants are also increasing their reach in the chaos since Muammar Gaddafi's fall in 2011.

The South Korean foreign ministry official said the government was considering relocating the embassy, without elaborating.