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.
The Union of Vilnius was based on the Union of Horodło of 1413. It was an alliance of two equal states. It was agreed that future rulers of both countries would be chosen separately, but with consent of the other state. The Union also provided for mutual aid and assistance in various armed conflicts. Historian Tomas Baranauskas interpreted it as the most advantageous for Lithuania of all Polish–Lithuanian unions. However, almost immediately Polish nobles began protesting the union on a technicality – the act referenced the Union of Horodło, which they did not have available.