The Ottoman palace coups of 1807–08 refers to several coups and rebellions deposing or restoring the throne of three Ottoman sultans that took place as a result of the attempted reforms of Selim III.
The Ottoman Empire was in decline by the early 19th century, and had lost much of the territory it had ruled over only a century earlier. However, the threat of the conservative, traditionalist Janissaries, the sultan's elite troops, prevented reforms from being enacted by more liberal rulers. In 1789, Sultan Abdulhamid I died, and his nephew Selim III, the son of Abdulhamid's predecessor, ascended to the throne. Selim, a composer of some talent as well as an advocate of modernization, was inspired to a certain degree by the French Revolution, his efforts at Westernization culminating with a levy for new regular troops in 1805. The reforms, particularly the levy, angered the Janissaries and other conservative elements, who rose up and killed leading reform advocates.
On May 29, 1807, Selim was deposed by Janissaries led by the rebel leader Kabakçı Mustafa and quickly replaced by his cousin Mustafa IV, who incarcerated his predecessor in the relative comfort of the royal palace. Mustafa effectively pardoned the rebels and allied himself with the Janissaries, disbanding Selim's newly formed army.
However, the influential governor of Ruscuk, Mustafa Bayrakdar, became disenchanted with Mustafa and plotted his downfall. His efforts led to a second revolt in 1808. The imprisoned Selim was murdered on Mustafa's command, but Mustafa's brother and heir, Mahmud, escaped from his would-be assassins. Meanwhile, rebel troops surrounded the palace, to be mocked by Mustafa and his officials, who even showed the rebels the body of Selim, in the vain hope that it would deter them. The rebels entered the palace anyway, arresting Mustafa and declaring Mahmud sultan.
While incarcerated in the palace, Selim had taught ideas of reform to Mahmud, who continued the reforms that had been stopped by the Janissary coup in 1807. Mahmud had appointed as grand vizier Mustafa Bayrakdar, leader of the rebellion that had installed him as sultan, and the reforms that the pair implemented angered the Janissaries once again.
In an attempt to cow Mahmud, the Janissaries staged a brief uprising and killed the vizier, forcing the sultan to call off the reforms and disband the army, which had been based on Selim's model, yet again.
Mahmud, although angering the Janissaries early on, managed to reign for several more decades. By 1826, he had become less afraid of the Janissaries and, in the Auspicious Incident, intentionally, some historians claim, caused the unit to rebel. He called out his regular troops and, using artillery to bombard the Janissary headquarters, destroyed the elite troops' capability to fight. He arrested the survivors, executing them shortly afterward. Now, without having to fear a coup, Mahmud pursued military and social reforms that, although modernizing the empire, did not stop its decline.