(Adds arrests, war context)
ALGIERS, Jan 16 (Reuters) - Police clashed with demonstrators in Algiers after rioting broke out at the end of a protest against the publication of cartoons depicting the Prophet Mohammad in the French satirical magazine Charlie Hebdo.
Several officers were injured during the violence, with small groups of protesters hurling rocks, fireworks and bottles at the security forces around the waterfront area of the Algerian capital.
Dozens of people were arrested, and two Islamist leaders, Ali Belhadj and Hamadache Zeraoui, were detained for illegally organizing a march in Algiers where demonstrations are still banned, a security source said.
Hundreds of people, including women and children, had earlier marched peacefully through the capital chanting "God is Great," singing and waving placards saying "I am Mohammad" in French and Arabic to protest against Charlie Hebdo's cartoons.
"This is my religion. I am with my prophet and they criticized him," said Mohammed Rechache, a truck driver who took part in the Algiers march with his young son.
A trio of Islamist gunmen killed 17 people last week in France before they themselves were shot dead in three days of violence that began with an attack on the satirical magazine, long known for its cartoons on Islam and other religions, political leaders and celebrities.
Charlie Hebdo's first edition since the attack, published on Wednesday, featured another cartoon of the Prophet Mohammad on its front cover that critics saw as a new provocation.
"We're against those who criticize the Prophet Mohammad, but we are also against terrorism," said student Salem Benzamia, who was carrying a sign in English.
Two French-born brothers of Algerian origin shot dead staff of the magazine in last week's assault.
Algeria suffered a bloody war with Islamist militants in the 1990s when around 200,000 people were killed during a conflict where whole villages were sometimes massacred and extremists fought to create an Islamic state.
Before the war, Islamist political movements would organize marches of tens of thousands to hear speeches in the capital. The army canceled 1991 elections that the Islamists looked set to win, pushing the country into nearly a decade of conflict. (Reporting by Patrick Markey; editing by Andrew Roche and Crispian Balmer)