Somalia: Failed State
Lighting up Somalia
Struggle for unity
In pictures: Camp life
Some 160 Somali religious scholars have issued a fatwa denouncing al-Shabab, saying the group had no place in Islam.
Correspondents say it is the first time Somali religious leaders have come up with a fatwa against the group, which controls many rural areas.
At a conference on the phenomenon of extremism in Mogadishu, the scholars said they condemned al-Shabab's use of violence.
Al-Shabab, or "The Youth", is fighting to create an Islamic state in Somalia.
Despite being pushed out of key cities in the past two years, it still remains in control of smaller towns and large swathes of the countryside.
The announcement comes as residents of central Somalia say al-Shabab executed a young man in the town of Bula Burte and performed a double amputation on another in front of a crowd of several hundred people.
Mary HarperBBC Somalia analyst
The issuing of the fatwa is a bold move, and a powerful one.
The religious scholars, especially those based in Somalia, have placed themselves at considerable personal risk. Al-Shabab does not hesitate to kill those it perceives as enemies.
The Somali government, which organised the conference, will be pleased it received an endorsement from the scholars, as they are widely respected.
But people are unlikely to pay much attention to the fatwa, especially the ban on joining al-Shabab. Alternatives need to be found, especially for the young men who serve as cannon fodder for the group.
The launch of a new campaign to get a million more Somali children into school might help, although schools themselves have ended up being used as recruitment centres by al-Shabab.
One of the aims of the conference was to issue Islamic opinion on whether the group had legitimacy or not, with the final fatwa concluding that it is not an Islamic movement, Sheikh Hassan Jaamai told the BBC.
"It's like a gang that comes together to kill Somalis... without any legitimate reason or justification," added the Islamic scholar, who flew over from the US to take part in the conference.
"The only thing they want is to create chaos in the country so that they can survive, " said another participant from the Gulf, Sheikh Abdikani, referring to bomb attacks on a restaurant in central Mogadishu that killed 15 people on the opening day of the meeting.
Al-Shabab said it carried out the attacks.
Somali President Hassan Sheikh Mohamud opened the government-organised conference that drew Somali scholars, elders and imams from both within the country and abroad.
At the end of the four-day conference, the seven points of the religious edict were read out by Islamic scholar Sheikh Abdirizak Ahmed Mohamud:
• "Al-Shabab has strayed from the correct path of Islam, leading the Somali people onto the wrong path. The ideology they are spreading is a danger to the Islamic religion and the existence of the Somali society.
• "The Somali government is an Islamic administration; it is forbidden to fight against it or regard its members as infidels.
• "Al-Shabab, an extremist group, must atone to God and must cease its erroneous ideology and criminal actions.
• "It is forbidden to join, sympathise or give any kind of support to al-Shabab.
• "It is a religious duty to refuse shelter to al-Shabab members, who must be handed over to Somali institutions responsible for security.
• "It is a taboo to negotiate on behalf of al-Shabab members in custody or release them from jail.
• "Somali officials have a religious duty to protect the Somali people from the atrocities of al-Shabab. The Somali public also has an obligation to assist the government in its security operations against al-Shabab."
Nairobi-based Somali analyst Mohamed Abdullahi told the BBC's Newsday programme that the fatwa, issued by so many prominent scholars, is likely to sway opinions on the ground, but is unlikely to change the path of those in the group's top leadership.
"The fatwa includes a security element of community policing against al-Shabab," he said.
But it should be coupled with other efforts to win the hearts and minds of people on the ground, he added.
"There must be another parallel programme to ensure that those young men who joined for economic reasons, for instance, are provided with employment or opportunities as well as convincing those who are really not extremist in ideology."
Last week, al-Shabab's Twitter account was suspended for a second time after claiming on its feed that it had ambushed the convoy of the president, who was unhurt.
It has since set up a new account.
President Mohamud took office a year ago in a UN-backed bid to end two decades of violence, with clan-based warlords, Islamist militants and its neighbours all battling for control of the country.