The war broke out in 1805–1806 against the background of the Napoleonic Wars. In 1806, Sultan Selim III, encouraged by the Russian defeat at Austerlitz and advised by the French Empire, deposed the pro-Russian Constantine Ypsilantis as Hospodar of the Principality of Wallachia and Alexander Mourousis as Hospodar of Moldavia, both Ottoman vassal states. Simultaneously, the French Empire occupied Dalmatia and threatened to penetrate the Danubian principalities at any time. In order to safeguard the Russian border against a possible French attack, a 40,000-strong Russian contingent advanced into Moldavia and Wallachia. The Sultan reacted by blocking the Dardanelles to Russian ships and declared war on Russia.