The prominent Somali singer-songwriter turned politician Saado Ali Warsame was shot dead Wednesday in the capital Mogadishu in the latest attack by Shebab insurgents against the government, police and witnesses said.

The shooting, with gunmen spraying her car with bullets before escaping, is the latest in a string of shootings or bombings targeting government officials.

Witnesses said armed men ambushed Warsame's car as it was travelling in the south of the capital, killing her and her driver.

Warsame is the fourth Somali lawmaker to be killed since the start of the year.

Somalia's Al-Qaeda-linked Shebab, who threatened earlier this year to kill the country's MPs "one by one", claimed responsibility for the attack.

"She was killed because she was an MP – all the lawmakers are sentenced to death until they leave parliament," Shebab spokesman Abdulaziz Abu Musab told AFP. "Whether she was singing or not is not our business."

Warsame was one of only around 30 female MPs in parliament.

The Shebab have intensified attacks during the ongoing Muslim holy month of Ramadan, and Musab said the Islamists would continue to "kill all the other MPs and government officials, whenever we get the opportunity."

Witnesses said the gunmen had trailed the lawmaker in car before attacking.

"I saw the gunmen driving in a car following the MP, then they opened fire … she died instantly and the gunmen then escaped," said Abdukadir Ali, a witness. "The dead body of the lawmaker and her driver were left in a pool of blood."

Warsame was famous for her songs in the 1970s, when she sang about political and social justice in opposition to the hardline rule of then dictator Siad Barre before he was toppled in 1991, an event that triggered the all-out civil war in Somalia that still drags on today.

The singer spent several years in exile in the United States during Somalia's worst years of fighting.

"As a singer, songwriter, poet and parliamentarian, Warsame exemplified all the best qualities of Somali culture and tradition," the US State Department said in a statement.

"This attack is yet another example of Al-Shebab's disrespect for the principles of peace, justice and compassion that Somalis everywhere are commemorating during the holy month of Ramadan," it added.

UN envoy Nicholas Kay condemned the killing of Warsame, saying her "loss will be felt across Somalia."

Shebab fighters fled fixed positions in Mogadishu three years ago and have since lost most large towns to a 22,000-strong UN-backed African Union force, fighting alongside government soldiers.

But they still hold sway in vast swathes of the rural hinterland from which they regularly launch guerrilla raids.

Recent Shebab attacks in Somalia have targeted key areas of government and security forces in an apparent bid to discredit claims by the authorities and AU troops that they are winning the war.

While the AU force launched a fresh offensive in March against Shebab bases, seizing a series of towns, the insurgents have largely fled in advance and suffered few casualties.

Earlier this month the Shebab launched an assault on the presidential palace using similar tactics as an attack on the same fortified compound in February.

In May, the Islamist insurgents also launched a similar attack against the national parliament.