MOGADISHU, Somalia — Three suicide bombers attacked the temporary residence of the new president of Somalia as he was giving a news conference on Wednesday, killing an African Union soldier but failing to assassinate any political leaders, witnesses and officials said.

The Somali president, Hassan Sheik Mohamud, had only just been elected to his post by the newly created Parliament on Monday, taking the helm of a fledgling government that is supposed to represent a tangible step toward permanent governance in a country that has been without it for more than 20 years.

Two of the suicide bombers struck, one near the gate and one at the back of the Jazeera Hotel near the airport as the president was giving a briefing for the news media with the visiting Kenyan foreign minister, Samson K. Ongeri.

Another attacker was shot as he tried to scale the walls of the compound, according to a statement from the African Union peacekeeping mission in Somalia.