The need to modernize a military system engaged in a losing struggle to maintain Ottoman control over the Mediterranean littoral and the Middle East was recognized by the first of the reforming sultans, Selim III (r. 1789-1807). He introduced French instructors to train the soldiers of a new volunteer army organized along the lines of contemporary European armed forces. However, his efforts were successfully resisted by the janissaries, who concluded that reform foreshadowed an end to their traditional privileges. Rising up in 1807, the janissaries precipitated the sultan's abdication and the dismantling of the new army. Mahmud II (r. 1808-39) eventually became strong enough to challenge the power of the traditional military caste. He reinstituted the reformed army and, in 1826, crushed the janissaries with a massive artillery barrage aimed at their barracks.