 At the same time, Lithuania was attacked by Ivan III of Russia, and in 1499 both nations signed the Union of Kraków and Vilna, which returned the Polish – Lithuanian alliance.In 1500 Jan Olbracht died, and on October 3, 1501, Aleksander Jagiellonczyk became the King of Poland.His election worsened the position of the Lithuanians, who agreed to the Union of Mielnik.