A bomber disguised as a woman attacked a graduation ceremony in Somalia on Thursday, turning a rare reason to celebrate into carnage that killed at least 22 people — including medical students, doctors and three government ministers.

The blast was blamed on Islamic militants who have shown a rising ability to carry out sophisticated large-scale bombings against high-profile targets — and highlighted the inability of Somalia's weak government to protect even the small section of the capital it controls.

"Today should have been a day of celebration — not mourning," said Somalia's ambassador to Kenya, Mohamed Ali Nur. "The hopes of many parents who eagerly awaited their sons' graduation were recklessly dashed ... cutting short the lives of ambitious Somalis."

Several hundred people had gathered in the Shamo Hotel to watch the 43 medical, engineering and computer science students from Benadir University receive their diplomas when the blast ripped through the festively decorated ballroom.

Amateur video of the attack obtained by AP Television News showed the dead, including at least three journalists, lying in pools of blood amid the sound of wails and screams from the wounded. Soldiers, their AK-47 rifles slung over their shoulders, picked through the wreckage with their hands as survivors climbed over the debris of the bombed-out room.

The attack targeted one of Somalia's most important efforts to extricate itself from anarchy and violence, explaining the presence of so many top government officials. The graduating medical students were only the second class to receive diplomas from the medical school.

"The loss of our ministers is disastrous, but it is an outrage to target the graduation of medical students and kill those whose only aim in life was to help those most in need in our stricken country," Somali Prime Minister Omar Sharmarke said.

Before last year's graduation, almost two decades had passed since anyone earned a medical degree in Somalia. At the December 2008 ceremony, graduates proudly hoisted their diplomas into the air.

This year, there was mayhem as the bomb went off while a Somali official addressed the gathering, sending metal shards and other debris flying and leaving dead and wounded in bloody heaps.

The bomb exploded about a yard from journalists covering the event.

"The explosion occurred really close to me, about a meter away. I jumped over some of the dead people laying on the ground and I went outside," said Associated Press reporter Mohamed Olad Hassan.

"What I think is I was lucky and people who were next to me, closer to the explosion shielded me from the explosion. The explosion was still thundering in my ears when I got back to the office."

Abdul Rahman Bukhari, a reporter for the Saudi-owned Al-Arabiya television station whose colleague, cameraman Hassan Zubeir, was killed, said the bombing "was the worst moment of my life."

After the attack, overturned white plastic chairs and tables littered the floor, which was stained red with blood. A single sandal lay in a pool of congealed blood, along with a briefcase and graduation programs.

Bodies, some draped with blue cloths, lay alongside the wounded. One man in khaki pants and a white shirt sat in his own blood, twisting his head to watch as victims were dragged out of the building.

On the steps outside, a dead man lay doubled over, his head resting on the blood-soaked ground as though he were praying.

Sharmarke said it was "beneath contempt" to attack and kill students and called for urgent help from the international community to prevent the further rise of al-Shabab, a militant group with links to al-Qaida.

"What happened today is a national disaster," said Somali Information Minister Dahir Mohamud Gelle, who confirmed that the ministers for education, higher education and health were killed in the blast. The ministers for sports and tourism were among the 46 wounded, he said.

Twenty-two people were killed, along with the suicide bomber, Gelle said. The bomber "disguised himself as a woman, complete with a veil and a female's shoes," he said.

No group immediately claimed responsibility, but suspicion fell upon al-Shabab, which controls much of the country and has carried out past suicide attacks.

African troops protecting the government wage near daily battles with Islamic militants who hold much of central and southern Somalia. Bombings have become deadlier as al-Shabab militants receive training from Arab militants and veteran insurgents from the Afghanistan and Pakistan conflicts.

Three journalists were reported killed. Besides Zubeir, two other Somali journalists working for local outlets also died, said Bashir Khalif, a reporter for the Somali government's radio service.

The Committee to Protect Journalists confirmed the deaths of two journalists, bringing the number killed in Somalia this year to nine.

"Somalia is the worst place for journalism in Africa and is very close to being the worst place in the world," said a committee official, Tom Rhodes. "Reporters are not only the victims of the conflict but the targets of the conflict."

Top Somali officials, including the president and prime minister, met for an emergency session at the presidential palace after the attack.

Benadir University was established in 2002 by a group of Somali doctors who wanted to promote higher education in a country where physicians have become victims of the seemingly endless violence. Medical degrees are obtained there after six years of study.

More than 500 students are enrolled in the university, according to its Web site, which said the school "strives to establish an open system of innovation and critical thinking similar to that in developed countries."

Governments and organizations around the world condemned the attack, including a joint statement issued by the U.S., European Union, U.N., African Union and the Arab League.

U.N. Secretary-General Ban Ki-moon said in a statement the bombing marred "what should have been an event filled with hope for Somalia."

Somalia has been ravaged by violence since warlords overthrew dictator Mohamed Siad Barre in 1991, then turned on each other. A moderate Islamist was elected president in January amid hopes he could unite the country's feuding factions, but the violence has continued.

Homicide bombings, unheard of in Somalia before 2007, have become increasingly frequent and the lawlessness has raised concerns that Al Qaeda is trying to gain a foothold in the Horn of Africa. The anarchy has also allowed piracy to flourish off the country's coast.

The three ministers killed in the blast were Qamar Aden Ali, the health minister and a British citizen; Ibrahim Hassan Adow, the minister for higher education and an American citizen, and Ahmed Abdullahi Wayel, the minister for education.