Poland and Lithuania had been joined in a personal union since the Union of Krewo of 1385. Both countries were ruled by Władysław II Jagiełło. However, after the Lithuanian Civil War (1389–1392) and the Ostrów Agreement, Vytautas gained the supreme power in Lithuania. The legal basis for Polish–Lithuanian relations was revisited by the Union of Vilnius and Radom of 1401, which reiterated "de facto" Lithuanian independence and "de jure" Polish supremacy. Vytautas was to be known by the title of Grand Duke ("magnus dux") and enjoyed vast power in Lithuania, while technically he was subordinate to Władysław II Jagiełło, 'Supreme Duke' ("supremus dux") and King of Poland. The union was signed after Vytautas' army was soundly defeated in the Battle of the Vorskla River and weakened Lithuania was looking for Polish support. Taking advantage of the Lithuanian defeat, the Principality of Smolensk, Veliky Novgorod, and Pskov rebelled against Lithuanian rule, drawing Vytautas into a war with the Grand Duchy of Moscow. However, within a few years peace was re-established in the east.