Militants claiming loyalty to the Islamic State group said on Twitter on Monday that they were responsible for an attack on the Moroccan embassy and on South Korea’s mission in Tripoli, Libya. (Reuters)

A message purported released by the Islamic State claimed responsibility Monday for twin attacks on diplomatic compounds in Libya’s capital in the latest apparent strikes by the militants in North Africa.

The violence in Tripoli – a bomb explosion Monday outside the Moroccan Embassy and deadly gunfire Sunday on the South Korea’s Embassy – came less than a month after suspected Islamic State gunmen targeted foreign tourists at a museum in neighboring Tunisia, claiming a total of 23 lives.

Groups pledging loyalty to the Islamic State have taken advantage of Libya’s internal political chaos to gain new footholds, including stepping up attacks on foreigners.

The claim by Islamic State, which appeared on Twitter and militant Web sites, did not give a specific reason for the embassy attacks. Its authenticity could not be independently verified, but the Islamic State has carried out previous attacks in Libya’s capital.

Morocco has close ties with some of the Islamic State’s main regional foes, including Jordan, and backed an Arab League plan last month to create a rapid-reaction force to intervene in crises in the Middle East and North Africa. South Korea has contributed humanitarian aid to those suffering from the Islamic State’s gains in Iraq and Syria.

The explosion outside the Moroccan Embassy caused some damage, but no injuries, security officials told The Associated Press.

On Sunday, gunmen fired on the South Korean Embassy, killing two guards, officials said in Seoul.

In January, attackers believed linked to the Islamic State stormed Tripoli’s Corinthia hotel, a main spot for foreign visitors, killing 10 people including an American security contractor.

A month later, the Islamic State militant beheaded 21 migrant workers in Libya – all but one Coptic Christians from Egypt. In retaliation, Egypt launched airstrikes on suspected Islamic State strongholds in Libya.

Read more:

Libya’s deepening quagmire

Islamic State versus al-Qaeda