[1] In September, Charles XII of Sweden allied himself with the Sapieha family in the ongoing Lithuanian power struggle, for their support against Augustus II (ruler of the Polish–Lithuanian Commonwealth).
[3] To aid Augustus against Charles XII and the newly elected Polish king Stanisław Leszczyński, Czar Peter I sent the vanguard of the Russian main army—which had previously been used against Swedish Ingria and Livonia—into northeastern Lithuania in September 1704.
[4] The vanguard was led by Anikita Repnin, who was instructed to gather supplies at Polotsk for the Russian main army and to lift the Swedish siege of the Biržai Castle, bordering Courland and Lithuania.
[9][a] After having beaten several detachments of Grzegorz Antoni Ogiński's Lithuanians in January, chasing them as far as to the Prussian border, the line of communication was reopened.
[14] At 06:30, the fog began clearing up and Danckwardt could finally see the enemies on the open field,[16] drawn up in a battle formation of two lines.
[18] Budberg's group engaged the Russian dragoons at the allies' left flank, which resisted fiercely until they were completely overthrown with 200 men killed.
[19] Danckwardt's detachment was later reinforced with 1,000 men,[20] and fought several skirmishes against dispersed Russian and Lithuanian units after the battle, before rendezvousing with Lewenhaupt.
[18] The Swedish general had launched an offensive with 6,000 men from Joniškis on 8 February and planned to march through Raseiniai, where 5,000 Russian dragoons were stationed, to Ukmergė.
[19] During his march towards Raseiniai, which was evacuated by the enemy, Lewenhaupt received alarming reports of Russian preparations to attack Riga which convinced him to cancel the offensive.
[21] In June 1705, the Russians sent a force under Boris Sheremetev to invade Courland and cut Lewenhaupt off from Riga, to secure the rear before the confrontation against Charles XII.