Government
Baghdad was under the rule of the Ottoman Empire Sultans. These sultans changed over time which influenced the city.
The Ottoman Empire stared to decline in 1566 and continued until 1807. In 1571 Venice, Spain and the Papal States combined their fleets and defeated the Turks in the naval battle of Lepanto. Lepanto is off the coast of Greece. At the time Selim II was the ruler of the Ottoman Empire. However, the empire was able to rebuild its navy and go back to controlling the Mediterranean.
The central government of the Ottoman Empire started to weaken and parts of the empire stared to act independently. The army of the empire was still too strong for rebellions against it. Murad III ruled between 1574-1594 and under his command new campaigns occurred to bring the empire to the peak of its territorial extent.
In the east Shah Abbas I brought anarchy to an end. He also conquered Iraq in 1624. After doing this he threatened to take control of the entire Ottoman Empire. However, Murad IV retook Iraq in 1638 from Shah Abbas. Then in 1656, Kiuprili Mahomed Pasha was made Grand Vizier and thanks to his efforts, the Ottoman Empire regained much of the power it had lost.

Murad IV
http://www.students.cs.ruu.nl/people/tgulteki/osmanli.html
Sultan Ahmed III who ruled in 1703-30 built several summer residences on the Bosporus and the Golden Horn. Members of his immediate entourage built similarly lavish houses, holding garden parties in imitation of the pleasures of Versailles. The sultan and his ministers were no longer confined behind the walls of the Topkapi palace beginning in the so-called Tulip Period - Lale Devri (1717-30). Some Ottomans under the influence of the grand vizier Ibrahim Pasa began to dress like Europeans The palace began to imitate European court life and pleasures. Growing tulips became an obsession with rich and poor, signifying Westernization, and the flower gave its name to the period. In 1727 Ibrahim Müteferrika, a Hungarian convert, printed Turkish-language books for the first time in the empire.
In 1723, during war with Persia, parts of Iran close to the Iraq boundary were taken and made part of the Ottoman territories and the Peace of Hemedan was signed in 1727. Hemedan and Tebriz were soon lost to the Shah, however, and the Patrona Riot broke out in Istanbul. Ibrahim Pasha was slaughtered and Ahmed III dethroned from his sultanate. The most successful and lasting Ottoman military reform during this time came in the navy. The navy was modernized by the grand admiral Gazi Hasan Pasa with the support and encouragement of the Sultan Abdülhamid I. This success came largely because the Ottoman naval establishment was devastated in 1770 at the Battle of Çesme by a Russian fleet that had sailed from the Baltic Sea, and there was none of the inbred resistance that stifled significant reforms elsewhere. Important reforms introduced into the army under the grand vizier Halil Hamid Pasa with the help of Western technicians were limited to new corps specially created for the purpose. The bulk of the Ottoman army remained unchanged and therefore was more equipped to suppress reform at home than to challenge modern Western armies.

Selim III
http://www.students.cs.ruu.nl/people/tgulteki/osmanli.html
These 18th-century reform efforts ended during the reign
of Selim III who was often considered the originator of modern reform in
the Ottoman Empire. While still a prince, Selim III developed plans for
modernizing the Ottoman army. He came to the throne during the 1787-92 war
with Austria and Russia and had to postpone serious reform efforts until
the war's completion. His efforts met opposition so large that he decided
to form a new army. This army was modeled after a European army with advanced
weapons and tactics. This new army was called nizam-i cedid.