The Union of Kraków and Vilna also known as Union of Vilnius was one of the agreements of the Polish–Lithuanian union. It was signed in Kraków by Polish nobility on 6 May 1499 and Vilnius by Lithuanian nobility on 24 July 1499.
Casimir IV Jagiellon was both King of Poland and Grand Duke of Lithuania. In his last will Casimir stipulated that the two states would be ruled by separately two of his sons. Thus after his death in 1492, John I Albert was elected to the Polish throne, while the Lithuanian Council of Lords chose Alexander Jagiellon. Thus the personal union between Poland an Lithuania was broken. The union at that time could be described as a dynastic union.
In late 1490s, Poland faced pressure from the Crimean Khanate and the Ottoman Empire, while Lithuania faced the Grand Duchy of Moscow. Ivan III of Russia claimed that he inherited rights to all Russian and Orthodox lands after the fall of the Byzantine Empire. His ambitions led to beginnings of the century-long Muscovite–Lithuanian Wars. After the Tatars invaded Volhynia and Podolia in late 1494, John Albert suggested a military and further political alliance to his brother Alexander. He agreed, but negotiations dragged until spring 1498, when the Tatars invaded Podolia and Galicia and took thousands of prisoners. Reacting to these threats and wishing to secure Lithuanian military assistance, Polish nobles agreed with all Lithuanian suggestions and demands.