A car bomb attack by the al-Qaeda linked Somali group al-Shabab has injured four United Nations guards in Mogadishu in an explosion targeting the UN's compound in the city.

A police officer at the scene of the blast confirmed to Reuters news agency that a total of four guards were injured in the blast, as al-Shabab claimed responsibility.

"We are behind the blast that injured at least three UN guards this morning," al Shabab's spokesperson on military operations, Sheikh Abdiasis Abu Musab was quoted as saying.

The bomb had been planted by al-Shabab in a car park just outside the UN facility which belongs to the United Nations Development Programme (UNDP).

The attack on the UNDP building comes less than 48 hours after a suicide bomber detonated a car bomb at Mogadishu airport, killing three. Security forces explained the bomb detonated as security forces were searching cars at a checkpoint, not far from the main base of the African Union peacekeeping mission.

The checkpoint is close to United Nations offices and blew tiles off nearby buildings.