A car bomb has exploded at the gate of the compound of the presidential palace in Somalia's capital Mogadishu, killing at least four people, police said.

Ali Hussein, a police officer, told the Reuters news agency that more than a dozen were also wounded after the assailant rammed the vehicle near soldiers guarding the official residence of the president, prime minister and the speaker of parliament.

Hussein added that the attack may have been aimed at a United Nations convoy that left the palace just before the blast.

Mohamed Hussein, another officer, told the Associated Press news agency that the bomber appeared to target foreign officials who were leaving the building, killing two of them.

At least two soldiers were also killed in the blast, he added.

A Reuters reporter also saw  damage to the gate of the compound, as well as five burnt-out cars at the scene.

Abdi Fatah, a witness in the area, told Al Jazeera that the blast occured in front of Villa Somalia, a building that serves as the official presidential palace and principal workplace of the president. 

There was no immediate claim of responsibility from the armed group al-Shabab, which is trying to overthrow President Hassan Sheikh Mohamud's government. But the group has repeatedly staged similar attacks on government buildings and officials.

Ahmed Aden, a resident in the area, said he had heard a loud blast followed by gunfire.

"Now we see huge smoke coming from the scene. Soldiers surrounded the area and we can only see ambulances rushing in and out," Aden said.

Mohamed Abdullahi, another police officer, told Reuters the attack may have been aimed at palace guards who sit in the area.

Source: Al Jazeera and agencies