In May 1837, General Thomas Robert Bugeaud, then in command of Oran, negotiated the Treaty of Tafna with Abd al-Qādir, in which he effectively recognized Abd al-Qādir's control over much of the interior of what is now Algeria. Abd Al-Qādir used the treaty to consolidate his power over tribes throughout the interior, establishing new cities far from French control. He worked to motivate the population under French control to resist by peaceful and military means. Rivalries between clans and brotherhoods that had divided Algeria prior to the French invasion were resolved under his organization, wherein he divided controlled territory into districts, each one reinforced and in control of its own defense. Seeking to again face the French, he laid claim under the treaty to territory that included the main route between Algiers and Constantine. When French troops contested this claim in late 1839 by marching through a mountain defile known as the Iron Gates, Abd al-Qādir claimed a breach of the treaty, and renewed calls for jihad. In 1839 he launched the Mitidja Campaign led by the Kabyle commander Ahmed bin Salem, and the Arab Mohammed ben Allel. The campaign was a success, albeit the Algerian forces were routed in the battle of Oued El Alleug. Throughout 1840 he waged guerrilla war against the French in the provinces of Algiers and Oran. Valée's failures to end the war led to his replacement in December 1840 by General Bugeaud.
