[12][13][14][15][16][17][18][19][20] When Charles X Gustav of Sweden invaded Poland, captured Warsaw and announced his claims on the Russian conquests in the orbit of the Grand Duchy of Lithuania, Afanasy Ordin-Nashchokin (who led Russian diplomacy at the time) decided it was an opportune time to suspend hostilities against the weakened Polish–Lithuanian Commonwealth and to attack the rear of the Swedish Empire instead.
In July, a reserve force of the Russian army struck across Swedish Ingria and overran two key Baltic fortresses — Nöteborg and Nyen.
The main forces marched along the bank of the Western Dvina towards Riga, taking Daugavpils (see Siege of Dyneburg) and Koknese (see Storm of Kokenhusen) on their way.
On 20 December, Ordin-Nashchokin negotiated with Sweden the Treaty of Valiesar (Vallisaare), whereby Russia was allowed to keep the conquered territories in present-day Latvia and Estonia — Koknese, Aluksne, Dorpat, Nyslott — for three years.
When the term expired, Russia's military position in the Polish war had deteriorated to such a point that the tsar could not allow himself to be involved into a new conflict against powerful Sweden.