The Agha of the Janissaries or Janissary Agha (Turkish: Yeniçeri a?as?) was a top Ottoman military official and courtier, and the commander of the Janissary corps. Apart from the commander-general of the entire corps, the title of "Agha of the Janissaries" was also be borne by the commander of a provincial garrison of Janissaries.
The Agha was chosen by the Ottoman Sultan, but was not necessarily himself a Janissary. To secure the often uncertain loyalty of the corps, Bayezid II (r. 1481-1512) stopped the practice of appointing the sekban-bashi (the commander of the sekban regiments) to the post, and instead nominated a member of his own household to the post. At the same time, Bayezid founded the A?a Bölükleri ("Agha's Troops") regiments, initially as the Agha's personal retinue and a means of controlling the corps; eventually these became regular Janissary units, and by the end of the 16th century there were 61 A?a Bölükleri regiments. During the Devshirme system, the Agha was responsible for checking the new recruited boys on arrival at Istanbul for falsifications or missing persons; his subordinates then examined the boys and allocated them either to the palace service or to the Janissary corps. As the Janissaries' political role increased in the early 17th century, from 1641 on the Aghas were once again appointed from among the Janissary corps.
Contrary to widespread modern perception of the Janissary corps as a monolithic and rigidly organized entity, the individual regiments (ortas) were not only the primary unit of organization, but also the focus of Janissary corps spirit and loyalty. Except for the commander (çorbac? or bölük a?a), all officers within each orta were exclusively drawn from and selected by members of the same regiment based on seniority or merit. Thus, while the Janissary Aghas could and did appoint protég?s and trusted aides to commands and thereby had a measure of influence within the individual regiments, their ability to exercise direct control was limited. In addition, the corps lacked a dedicated military staff, with the Agha assisted only by a few civilian officials. This was not a problem while the Janissaries where a small force of about 1,000 troops, but prohibited any effective operational control once the corps mushroomed to 15,000 and more in the course of the 16th and 17th centuries. The usually brief tenures of the Aghas further contributed to their lack of control over the corps.
The Agha of the Janissaries had his own residence, the so-called "Agha's Gate" (a?a kap?s?) next to the Suleymaniye Mosque, overlooking the Golden Horn. As a senior member of the court, with the right of direct and private audience with the Sultan, the Agha was a very influential figure in Ottoman politics, and one of the closest advisors of the Sultan. Along with the Grand Vizier, the Agha of the Janissaries was also responsible for maintaining order in the Ottoman capital, Istanbul. The Agha also had prominent ceremonial and protocollary duties; for example, he accompanied the Sultan on his ceremonial visits to the mosques of the capital for the Friday prayer. When the Agha was absent on campaign, his duties were carried out by his deputy, the sekban-bashi, the commander of the 34 sekban regiments, which always remained behind as garrison in the capital. On campaign, the Agha was preceded by a white horse-tail standard (tugh), and his attendants had the tails of their robes tucked into their girdles. In the 16th century, the Agha of the Janissaries was one of the fifteen "Aghas of the Stirrup", leading officials from the Sultan's household which according to law qualified for subsequent appointment as provincial governors.