Updated

Somalia's government fired the police and intelligence chiefs a day after Islamic militants attacked the heavily guarded presidential palace in the capital, Mogadishu, the information minister announced Wednesday.

Government troops and African Union peacekeepers repelled the attack and no government official was hurt, Mustafa Dhuhulow said. Three of the four extremist attackers were shot dead by soldiers after they forced their way into the presidential palace late Tuesday, sparking an exchange of gunfire, he said. The fourth militant was wounded.

Dhuhulow told reporters Wednesday that police commander Abdihakim Saaid and intelligence chief Bashir Gobe were replaced immediately.

A new minister for national security was also appointed in changes announced by Prime Minister Abdiweli Sheikh Ahmed, who was inside the palace when the attack happened. Dhuhulow said the government would implement sweeping new security measures to prevent such attacks.

The presidential compound -- known also as Villa Somalia -- houses several government offices and is considered one of the safest places in Mogadishu because of the tight security presence. However, it has been attacked many times by Al Qaeda-linked militants over the years.

The Islamic extremist group al-Shabab has vowed to step up attacks during the Muslim holy month of Ramadan and claimed responsibility for the attack.

The attack was the second assault on Villa Somalia this year and it was the first time militants were able to breach its compound and take offensive positions inside. The palace is protected by government troops and African Union peacekeepers who helped to drive the al-Shabab militants out of Mogadishu in 2011.

The U.S. government condemned the latest attack. Such attacks "demonstrate that insecurity in Mogadishu persists, including very real threats from al-Shabaab," said Jen Psaki, a State Department spokeswoman.

Somalia's government has not given details about how the attack was carried out, but some security officials said the four militants managed to infiltrate Villa Somalia by dressing as government troops. Amid the confusion some soldiers and guards fired at their comrades, said Yusuf Nor, a security official who was at the scene as the attack unfolded.

Somali police officials said the militants, who were armed with grenades, split up once inside and tried to take control of different buildings in the compound.

The Horn of African nation has been trying to rebuild following years of political instability and civil strife since 1991, when the dictator Siad Barre was ousted from power.

President Hassan Sheikh Mohamud's Western-backed government has promised to put the country on a path toward democracy and economic progress, despite regular attacks by Islamic militants.