The two rebel groups that seized control of the northern half of Mali have announced they are to fuse their movements and work together to create an independent Islamic state on the territory they occupy, a signatory to the agreement said.

Alghabass Ag Intalla, one of the leaders of Ansar Dine, which is fighting to create an Islamic state, confirmed that his movement was joining with the National Movement for the Liberation of the Azawad, a secular rebel group led by Tuareg separatists.

They signed the agreement in the northern town of Gao on Saturday evening, and celebratory gunfire rang out in both Gao and Timbuktu, another town under their control, as fighters heard the news.

"I have just signed an accord that will see an independent and Islamic state where we have Islamic law," Ag Intalla said.

It's one more worrying development for Mali, because Ansar Dine is known to have ties to al-Qaida in the Islamic Maghreb, the al-Qaida affiliate in Africa, which is responsible for dozens of suicide attacks as well as the kidnappings of foreigners, some of whom were later executed.

The two groups took over the north of Mali at the end of March, forcing Malian government troops to flee south. Until now, the two had been in disagreement because Ansar Dine wants to impose sharia law in the area they occupy, something the secular NMLA had been resisting.

Ansar Dine had also previously said they were opposed to the NMLA objective of creating an independent homeland for Mali's Tuaregs, a goal they now say they are backing.

During the rebel advance in March, residents said there were visible turf wars with the fighters occupying different areas of the cities under their control.

In Timbuktu, the last major town in the north to fall to the rebels, the NMLA took over the airport, located on the outskirts of town, while Ansar Dine installed itself in the military camp at the centre of the fabled city.

The two have different rebel flags, and witnesses reported seeing one group raise its flag over an administrative building, like the governor's residence, only for the second group to show up, and replace it with their own flag.

The agreement suggests that both sides have made a major concession in talks that have been going on intermittently for weeks.

The north of Mali fell after a coup d'etat in the capital Bamako on 21 March left government forces disorganised and lacking motivation to fight. The transitional government of Mali says it wants to take back the north, but so far the factions in Bamako have been too busy arguing over who is going to lead the transition to focus their attention on the issue of the north.