The nun, who was not immediately identified, was shot in the back at S.O.S. Hospital in northern Mogadishu by two gunmen, said Mohamed Yusuf, a doctor at the facility, which serves mothers and children. The nun's bodyguard and a hospital worker were also killed, doctors said.
There was no immediate claim of responsibility for the attack, and it was not clear if it was directly linked to the pope's comments. Two people had been arrested, said Yusuf Mohamed Siad, head of security for the Islamic militia that controls Mogadishu.
Earlier Sunday, a Somali cleric criticized the comments the pope made in a speech last week for offending Muslims. The pope had cited the words of a Byzantine emperor who characterized some of the teachings of the Prophet Muhammad, Islam's founder, as "evil and inhuman."
"The pope's statement at this time was not only wrong but irresponsible as well," said Sheik Nor Barud, deputy leader of the Somali Muslim Scholars Association.
"Both the Pope and the Byzantine Emperor he quoted are ignorant of Islam and it is noble Prophet," he told journalists at a news conference in the capital Mogadishu.
In Rome, Vatican spokesman Rev. Federico Lombardi called the nun's slaying "a horrible episode," the Italian news agency ANSA said. "Let's hope that it will be an isolated fact."
Lombardi indicated the shooting could be related to the uproar over the pope's remarks.
"We are following with concern the consequences of this wave of hate, hoping that it does not lead to grave consequences for the church in the world," he was quoted as saying.
for the angry reaction to his remarks, which he said came from a text that didn't reflect his personal opinion.
Witnesses also said the shooting and the pope's comments appeared to be linked.
"These gunmen always look for white people to kill, and now the pope gave them the reason to do their worst," said Mohamud Durguf Derow, who was at the scene when the nun was killed.
The nun, who spoke fluent Somali, was believed to be around 60 and had been working at the hospital since 2002, said witnesses at the hospital on condition of anonymity for fear of reprisals.
Somalia has been without an effective central government since warlords overthrew it's longtime dictator in 1991 and divided the nation into fiefdoms. The Islamic fundamentalists have stepped into the vacuum as an alternative military and political power.
The current interim government was established two years ago with the support of the United Nations, but has failed to assert any power outside its base in Baidoa, 150 miles from Mogadishu.
The Islamic group, which seized the capital and much of southern Somalia this summer, is credited with bringing a semblance of order to the country after years of anarchy, but some of its leaders have been linked to al Qaeda and there are fears of an emerging Taliban-style regime.