Explosions and gunfire have rocked the Mogadishu hotel where the newly elected Somali president was meeting with Kenya's foreign minister and other dignitaries.

A bomb exploded outside the gate, followed by an exchange of fire, leaving at least eight people dead on Wednesday.

A police officer said a Ugandan soldier from the regional force and two Somali troops were killed in the attack, adding that initial reports suggested it was carried out by three suicide bombers.

Two suicide bombers were shot and blew up while trying to enter the hotel, while a third bomber was shot dead as he tried to climb the compound wall, an AU statement said.

Al-Shabab, an Islamist group battling the Somali government, claimed responsibility for the attack through a spokesman.

The group has opposed Hassan Sheikh Mohamud's election, saying it was manipulated by the West.

"We are responsible for the attack against the so-called president and the delegation," Ali Mohamud Rage, the spokesman, told the AFP news agency.

Al Jazeera's Peter Greste, reporting from the Jazeera Palace hotel in Mogadishu where the attack occurred, said that two explosions took place, and that gunfire erupted immediately after the first blast.

Mohamud and Sam Ongeri, Kenya's foreign minister, escaped unharmed, he said.

Security challenge

Earlier, Colonel Ali Houmed, a spokesman for the African Union force in Somalia, said: "There has been a blast around the hotel where the president was. The president is safe. All the people who were inside the hotel are safe."

Mohamud was elected on Monday, beating Sharif Sheikh Ahmed, who was seeking re-election after leading a transitional government for three years.

Live Box 20129108523573103

"It's been several months since we've seen any kind of car-bomb attack in Mogadishu, and in that last incident, only one person was killed, and it was several months before that, since we've seen any significant loss of life here," our correspondent said.

"One of the things that will worry a lot of security analysts is the fact that al-Shabab seem to have very good intelligence ... The timing of the attack was absolutely perfect."

Mohamud spoke almost immediately after the blast.

"First and foremost we will address the security issue. Priority number one is security, and priority number two, and
priority number three," he said, moments after the blasts, continuing for several minutes before being whisked away by security staff.

He is expected to form a fully functioning government for Somalia, which has not had one since 1991, when a longtime dictator was overthrown.

Source: Al Jazeera and agencies