Explosions during attack on Nairobi hotel complex
Explosions during attack on Nairobi hotel complexReuters

The Al-Shabaab terrorist group said on Wednesday it carried out the deadly attack on a Nairobi hotel and office complex in retaliation for US President Donald Trump's declaration of Jerusalem as Israel's capital last December, AFP reported.

The group said in a statement picked up by the SITE monitoring group that its fighters stormed the DusitD2 complex on instructions by Al-Qaeda leader Ayman al-Zawahiri.

"It is a response to the witless remarks of the US president, Donald Trump, and his declaration of Al-Quds (Jerusalem) as the capital of Israel," said Al-Shabaab.

The assault with guns and explosives claimed the lives of 21 people as it unfolded Tuesday in the complex, which includes a 101-room hotel, spa, restaurant and offices.

All five of the terrorists were killed before an operation by rescue forces to rescue trapped civilians and clear buildings ended 20 hours later.

The Al-Shabaab statement was entitled: "Al-Quds (Jerusalem) will never be Judaized," according to SITE.

"Know that we will hold you to account for every Muslim blood spilt in Palestine; ounce for ounce," it said in part.

Nairobi was hit in 2013 by a terrorist attack which targeted the Westgate Mall and in which 67 people were killed.

That attack was also claimed by Al-Shabaab as retaliation for Kenya's military presence in Somalia.