In the summer of 1806, during the war with the Third Coalition (Britain, Russia, Prussia, Sweden), Napoleon's ambassador General Count Sebastiani managed to convince the Porte to cancel all special privileges granted to Russia in 1805 and to open the Turkish straits exclusively to French warships. In return, Napoleon promised to help the Sultan suppress a rebellion in Serbia and to recover lost Ottoman territories. When the Russian army marched into Moldavia and Wallachia in 1806, the Ottomans declared war on Russia.
During the Dardanelles Operation in September 1806, Britain pressured Sultan Selim III to expel Sebastiani, declare war on France, cede the Danubian Principalities to Russia, and surrender the Ottoman fleet, together with the forts on the Dardanelles, to the Royal Navy. After Selim's rejection of the ultimatum, a British squadron, commanded by Vice-admiral Sir John Thomas Duckworth, entered the Dardanelles on February 19, 1807 and destroyed an Ottoman naval force in the Sea of Marmara, and anchored opposite Istanbul. But the Turks erected powerful batteries and strengthen their fortifications with the help of General Sebastiani and French engineers. The British warships were cannonaded and Duckworth was forced to sail back to the Mediterranean on March 3, 1807.
On March 16, 1807, 5000 British troops embarked on the Alexandria expedition of 1807 and occupied Alexandria in August, although the local ruler Muhammad Ali of Egypt defeated them heavily and forced them to evacuate five months later after a short siege; however, Turkey had a little military support from France in the heavy war with Russia. Napoleon failed to secure Russia's compliance with the armistice agreement of 1807. Therefore, on January 5, 1809, the Ottoman government concluded the Treaty of the Dardanelles with Britain (being now in war with both France and Russia).