Six civilians have been shot dead by a Kenyan soldier advancing towards the al-Shabab stronghold of Kismayo, the Kenyan army has confirmed.

The soldier has been detained pending an investigation, it said, noting the incident followed a militant attack.

Somali army spokesman Adan Mohamed Hirsi earlier told the BBC it had been “a deliberate killing”.

Meanwhile, the Hizbul Islam group has announced that it is leaving the al-Shabab militant organisation.

BBC Somalia analyst Mohamed Mohamed says it is a significant setback for al-Shabab, following recent military defeats.

Kenyan troops intervened in Somalia a year ago after a spate of cross-border attacks blamed on the al-Qaeda-linked al-Shabab.

It was the first time Kenyan troops had been sent abroad, except as peacekeepers.

‘Hurtful’

Sunday’s shooting happened about 50km (30 miles) from Kismayo, the largest city still in militant hands.

Mr Hirsi condemned the killings and asked the Somali government to take action.

“This incident is very hurtful,” he told the BBC’s Somali service, saying a group of young men were shot outside a shop in the village of Janay Abdalla.

They were reportedly queuing to buy sugar.

In addition to those killed, two civilians were seriously wounded, Mr Hirsi said.

Kenyan military spokesman Col Cyrus Oguna said the incident happened shortly after al-Shabab militants attacked Kenyan soldiers who were escorting people to collect water from a well in the village, killing five civilians and one soldier.

“Later on in the day, several people approached KDF [Kenya Defence Forces] defensive positions, where a KDF soldier allegedly opened fire killing six people,” he said in a statement.

“The soldier was disarmed and has since been put on guarded seclusion,” he said, adding that appropriate action would be taken after the investigation.

Col Oguna said the Kenyan operations in Somalia should not be judged by this “unfortunate incident” and that the “utmost care and concern for civilian safety” were taken.

BBC East Africa correspondent Gabriel Gatehouse says Kenyan forces have in the past been accused of causing civilian deaths in Kismayo by shelling al-Shabab targets from ships operating off the coast.

Some 10,000 people have fled Kismayo in the past week, the United Nations refugee agency estimates.

‘Positive development’

Al-Shabab has been forced out of the capital, Mogadishu, and several other towns over the past year but still controls much of the countryside in south and central Somalia.

However, it still stages frequent attacks.

On Saturday, gunmen shot dead a member of Somalia’s new parliament in Mogadishu.

Mustafa Haji Maalim was gunned down after leaving a mosque in the southern Waberi district following evening prayers, witnesses said.

The dead lawmaker was the father-in-law of former President Sharif Sheikh Ahmed, and is the first parliamentarian to be targeted since a new 275-member assembly was selected in August.

No-one has so far claimed the attack, though al-Shabab has previously vowed to kill government officials.

On Thursday, a double suicide attack in Mogadishu targeting a restaurant recently opened by Somalis from the diaspora killed 18 people.

Hizbul Islam spokesman Mohamed Moalim told the BBC that his group still wanted the African Union mission to leave Somalia but welcomed the new president and parliament as a “positive development”.

He said the split was due to long-standing ideological differences, such as his group’s opposition to the use of foreign jihadis.

The two forces merged in 2010, following bitter clashes.

Since the overthrow of President Siad Barre in 1991, Somalia has seen clan-based warlords, Islamist militants and its neighbours all battling for control.