In the East, anarchy in Iran was brought to an end by Shah 'Abbas I, who not only restored Iranian power but also conquered Iraq (1624) and threatened to take the entire Ottoman Empire. Though Murad IV was able to retake Iraq (1638), Iran remained a major threat.
In 1645 the Castle of Hania on the island of Crete was lost to the Venetians, as was a large part of the island. Following this the Venetians attacked the coastal areas of Turkey with their fleet. Sultan Ibrahim was dethroned and his son Mehmed the Fourth took his place. Some sections of the Sultan's Bodyguard in Istanbul rebelled, while further rebellions were provoked by Djelal in Anatolia. The Ottoman Empire lost more land in Crete.
However, in 1656, Kiuprili Mahomed Pasha was made Grand Vizier and it was largely thanks to his efforts that the Ottoman Empire regained much of its power at this time. The rebellion in Istanbul was put down, a new war declared against Venice and Crete was regained after the defeat of the Venetian fleet.
Finally, a long war with Venice (1645-69), occasioned by Ottoman efforts to capture Crete, exposed Istanbul to a major Venetian naval attack. Although the Venetians finally were pushed back in a naval campaign culminating in the Ottoman conquest of Crete (1669), they still posed a major threat that, like those which had occurred earlier in the century, stimulated the ruling class to accept needed reforms.
Efforts were made to restore the timar and tax farm systems as the basis of the administration and army and to limit taxes to the limits imposed by law. Provincial revolts were suppressed, peasants were forced back to the land, and cultivation was increased. Debased coins were replaced by coins of full value. Industry and trade were encouraged, corrupt officials executed, and insubordination driven out.
Europe now faced by the Ottomans was far more powerful than that which the great sultans of the past had defeated; even if the reforms had been more permanently successful, they could not have corrected the increasing Ottoman weakness relative to the powerful nation-states then rising in Europe. Such an understanding was to come to the Ottoman reformers only in the 19th century.
War was declared against the King of Transylvania who had risen against the Ottomans. The fortress of Yanova and several other citadels were seized while the rebellion of Abaza Hassan Pasha was subdued. On the death of Kiuprili Mahomed Pasha in 1661, his son Fazyl Ahmed Pasha became Grand Vizier and war was declared on Austria. Kiuprili Fazyl Pasha was appointed Serdar-i Ekrem (Great Commander in Chief). The fortresses of Uyvar and Zerinvar were captured and Fazyl Pasha set out for Crete where the fortress of Kandiye was captured.
In 1666, on the condition that Venice retained some small castles, the island of Crete was annexed to Ottoman territories. A campaign was launched on Poland where the Cossacks were attacked and the castle at Kommaniche was taken. Fazyl Ahmed Pasha died in 1676 and Kara Moustapha Pasha took his place. The Castle of Cherin, previously held by the Russian Empire, was taken.
In 1683 Mehmed declared war on Austria again and Vienna besieged for the second time. However, due to treachery by the Khan of the Crimea, the Polish King, king Jan Sobieski (ruled 1674-96), not only held out but also built a major European coalition that was to bring destruction to the Ottoman Empire during the 18th century. The Habsburgs set out to reconquer Hungary, Serbia, and the Balkans, while Venice hoped to regain its naval bases along the Adriatic coast and in the Morea and to resume its naval and commercial power in the Levant, and Russia worked to extend its reach through the Bosporus, the Sea of Marmara, and the Dardanelles to the Aegean. was able to arrive to support the city and the Ottoman army was defeated. Austria, Venice and Poland formed an alliance against Turkey and, shortly afterwards, it was joined by the Russian Empire. The Ottomans were routed and, according to the Peace of Karlofcha in 1699, the Empire was divided up as follows:
Hungary, apart from Temeshvar, to Austria. Morea to Venice. Podolia and Kommaniche to Poland.
The fortress of Azoph went to Russia by the Treaty of Istanbul, 1700. Shortly after this, rebellions broke out again in Anatolia and Istanbul. Mehmed had been dethroned in 1687, being succeeded by Solyman the Second. He, in turn, had been succeeded by Ahmed the Second in 1691.
Attempts were made to retake land lost by the Treaties of Istanbul and Karlofcha. At one stage the Swiss King took refuge with the Ottomans. Subsequently there was another war with Russia. Under the command of Mehemet Pasha the Baltadji (Woodcutter) the Turks defeated Russian armies at Pruth and by the Peace of Pruth, 1711, the land given to Russia by the Treaty of Istanbul was given back. After war with Venice, Morea and other islands given to Venice by the Treaty of Karlofcha were also regained.