French troops continued to oppose Abd el-Kader's united Algerian tribes but lost many battles. In 1837, the Treaty of Tafna was signed, giving Abd el-Kader control of most of the interior of Algeria; France retained only a few ports. With his territorial acquisitions, Abd el-Kader organized a true Muslim state, using religious sentiment to unify the Algerians.
Although his forces were defeated by the French under General Thomas Bugeaud in 1836, Abd al Qadir negotiated a favorable peace treaty the next year. The treaty gained conditional recognition for Abd al Qadir's regime by defining the territory under its control and salvaged his prestige among the tribes just as the shaykhs were about to desert him.
By 1839 he controlled more than two-thirds of Algeria. His government maintained an army and a bureaucracy, collected taxes, supported education, undertook public works, and established agricultural and manufacturing cooperatives to stimulate economic activity...