In 1656, the second Russian army under the command of Trubetskoy advanced in the north of Swedish Livonia, besieged and captured Tartu. In 1659, a Russian army led by Aleksey Trubetskoy and Ukrainian cossacks under the command of Ivan Bezpaly crossed into the Ukraine and were partly defeated in a surprise attack by a large Polish-Tatar-Cossack army led by Mehmed IV Giray and Ivan Vyhovsky in the Battle of Konotop. The same year, he negotiated the Second Treaty of Pereiaslav with Yurii Khmelnytsky.