Gunmen entered the SOS Hospital in southern Mogadishu's Huriwa district and opened fire on the nun before escaping in the ensuing confusion, witnesses said.
Dr Ali Mohamed Hassan, a physician at the hospital, said: "After serious injuries, she died in the hospital treatment room. She was shot three times in the back."
The nun, believed to be in her 70s, was one of the longest-serving foreign members of the Catholic church in Somalia, officials told AFP news agency.
Unconfirmed reports said the nun's bodyguard had also been killed.
Yusuf Mohamed Siad, head of security with the Islamic courts who control Mogadishu, told AP news agency that the group had arrested two people, but did not give further details.
A Vatican spokesman called the killing "a horrible episode" and said it hoped that the incident would be "an isolated fact".
The killing comes as anger has risen among members of the country's popular Islamist movement over comments made by Pope Benedict that were deemed insulting to Islam.
On Friday, a prominent hardline Mogadishu cleric called for Muslims to "hunt down" and kill the pope for his remarks.
Sheikh Abubukar Hassan Malin said during Friday prayers: "Whoever offends our Prophet Mohammed should be killed on the spot by the nearest Muslim."
Armed men also shot and killed a 13-year-old boy on Sunday while breaking up a crowd watching an English Premiership football match in southern Mogadishu.
Witnesses said Muslim gunmen stormed the Duale cinema in Bulo-hubey district where hundreds had gathered for the Chelsea-Liverpool game and opened fire, killing the boy and wounding three others.
"I saw armed men pouring into the cinema hall and minutes later, they opened fire," Idris Abdi Taqtar told AFP, adding that his younger brother was among those wounded.
Islamist officials confirmed the death but blamed the fans for sparking the violence when they tried to prevent the closure of the cinema.
Ise Mohamed, an Islamist commander, said: "They tried to prevent the Islamic courts from carrying out its duties by making violence, so we dispersed them with gunfire."
Meanwhile, at least three people were killed and seven others wounded near the southern port of Kismayo on Sunday when Islamist gunmen fought with local fighters near the southern port of Kismayo, officials and witnesses said.