He came to the throne on the deposition of his brother, Mustafa IV, and continued the reforming policies of his cousin, Selim III (1789–1807). He rid himself of the Janissaries, the traditional military corps that had become unruly and inefficient, by having them massacred, and established a new, European-style army. He curbed the power of the religious classes, centralized government, and reduced provincial autonomy. He was attacked by Mehemet Ali of Egypt, and his army defeated in the battle of Nizip (1839) in Syria.