Alemdar Mustafa Pasha Alemdar Mustafa Pasha ( also called Bayraktar Mustafa Pasha ) was an Ottoman military commander and a Grand Vizier born in Khotyn in then Ottoman land Ukraine in 1765 . Both " alemdar " and " bairaktar " mean " the standard bearer " and were the names given to the same rank in the Janissary corps . He was originally the ayan ( provincial notable ) of Rusçuk , and one of the strongest ayan s of his time . The deposition of the reformer Sultan Selim III in 1807 , and his replacement with the reactionary Mustafa IV by the Janissaries and other opponents of reform , provoked Alemdar Mustafa Pasha to lead his army of Albanians and Bosnians to Constantinople in an attempt to reinstate Selim III and restore his reforms . After he arrived , Mustafa IV ordered Selim III and Mahmud II to be killed , he succeeded in getting the former killed . Alemdar Mustafa Pasha , seeing Selim III dead , showed fealty to Mahmud II ( Selim ' s cousin ) , and he was instated the sultan , with Alemdar as his Grand Vizier . As vizier , Bayrakdar purged the soldiers who had rebelled against Selim , removed conservatives from governmental positions and replaced them with men sympathetic to reform . Bayrakdar modernized the army and navy and attempted to reform the Janissaries , but Mahmud , fearing a political backlash of the elite corps , halted such change . Bayrakdar ' s power and influence and his arrogance wielding it caused a rebellion against his position . In November 1808 , the Janissairies attacked the Porte and laid siege to the stone powder magazine where he and his personal guard had taken refuge . As the Janissaries were about to break in the powder barrels exploded , killing Bayrakdar , his guard , and several hundred Janissaries . He rose through the Janissary corps . After having been promoted to commandership , he took part in the wars against Austria and Russian Empire . In 1808 , when the Sultan Mustafa IV ascended the throne with the help of the reactionaries who opposed the reform efforts undertook by Selim III , and the deposed Selim III was imprisoned , Alemdar Mustafa Pasha was the governor of the city of Rusçuk ( today " Rousse " ) in Bulgaria . The assault on Constantinople and fight against the reactionaries . Alemdar Mustafa Pasha had always been a keen supporter of Sultan Selim III . With Mustafa IV on the throne rule and the reactionary rebels commanded by Kabakçı Mustafa in command of the Ottoman capital , Mustafa Pasha gathered a council in Rusçuk and the council decided to take action . On 21 June 1808 , Alemdar Mustafa Pasha and his army of about 15 , 000 men came to İstanbul . They easily took control of the situation and with the order of Alemdar Mustafa Pasha , the rebels were killed or exiled . When Mustafa IV learned the events , he decided to have his uncle , Selim III , as well as his younger brother , Prince Mahmut , killed in order to remain the only member of the imperial family . The executioners arrived first in the room of Selim III in the palace . Selim III , who was playing reed flute and had no weapons , resisted with his flute , but his efforts proved futile and he was strangulated . His dead body was brought in front of Alemdar Mustafa Pasha , who began weeping , thinking having failed in all his objectives . While he was weeping , his men warned him that Mustafa IV ' s men were going to kill the Prince Mahmud as well . In fact , in those very moments , the executioners had raided the prince ' s room , the Prince was put to hiding in the roof by the servants . Alemdar Mustafa and his men arrived and broke the palace doors . They killed the rebels and eventually saved the prince . Alemdar Mustafa Pasha declared prince Mahmud the new sultan with the name Mahmud II , and he became his grand vizier . In the service of Sultan Mahmud II . But differences of opinion soon emerged between the two . First of all , he made an agreement with the rebel representative from Anatolian lands , which was named “ Sened - i Ittifak ” ( " " The Alliance Treaty " " ) . Sultan Mahmud thought that his authority was limited with that agreement and he lifted his support of the Pasha . Secondly , he re - established the army of Nizam - ı Cedid under a different name : Sekban - ı Jedid . Nizam - i Jedid army was an alternative to the corps of Janissaries , therefore the Janissaries were hateful against this army . Pasha ' s opting for another name can be explained with an effort in order not to anger Janissaries . Furthermore , he conducted an investigation among the Janissary corps and he fired the men who were not in fact Janissaries but receiving Janissary salaries all the same . His death . His steps would eventually lay the ground for further reforms in the Ottoman Empire . But in the meantime , the ruling elites were resentful of the Pasha . On 15 November 1808 , about a thousand Janissaries raided Alemdar Mustafa Pasha ' s house . Realizing he could not survive the assault , he ignited the gunpowder reserves that were place in the cellar of his house , killing himself and approximately 400 Janissaries in the ensuing explosion . Alemdar Mustafa Pasha was buried in the courtyard of the Zeynep Sultan Mosque in Istanbul . A street in Istanbul near the Sublime Porte is named after Alemdar Mustafa Pasha . A notice there states that his father was a Janissary from Ruscuk .