On 30 June 1876, Serbia, followed by Montenegro, declared war on the Ottoman Empire. In July and August, the ill-prepared and poorly equipped Serbian army helped by Russian volunteers failed to achieve offensive objectives but did manage to repulse the Ottoman offensive into Serbia. Meanwhile, Russia's Alexander II and Prince Gorchakov met Austria-Hungary's Franz Joseph I and Count Andrássy in the Reichstadt castle in Bohemia. No written agreement was made, but during the discussions, Russia agreed to support Austrian occupation of Bosnia and Herzegovina, and Austria-Hungary, in exchange, agreed to support the return of Southern Bessarabia – lost by Russia during the Crimean War – and Russian annexation of the port of Batum on the east coast of the Black Sea. Bulgaria was to become autonomous (independent, according to the Russian records).
As the fighting in Bosnia and Herzegovina continued, Serbia suffered a string of setbacks and asked the European powers to mediate an end to the war. A joint ultimatum by the European powers forced the Porte to give Serbia a one-month truce and start peace negotiations. Turkish peace conditions however were refused by European powers as too harsh. In early October, after the truce expired, the Turkish army resumed its offensive and the Serbian position quickly became desperate. On 31 October, Russia issued an ultimatum requiring the Ottoman Empire to stop the hostilities and sign a new truce with Serbia within 48 hours. This was supported by the partial mobilization of the Russian army (up to 20 divisions). The Sultan accepted the conditions of the ultimatum.