The Union of Horodło or Pact of Horodło was a set of three acts signed in the town of Horodło on 2 October 1413. The first act was signed by Władysław II Jagiełło, King of Poland, and Vytautas, Grand Duke of Lithuania. The second and third acts were composed by the Polish nobility (szlachta) and Lithuanian boyars, respectively. The union amended the earlier Polish–Lithuanian unions of Krewo and Vilnius–Radom. Politically, Lithuania received more autonomy as, after the death of Vytautas, the Lithuanian nobles could choose another Grand Duke instead of passing the title to Władysław II Jagiełło or his heir. However, culturally, Lithuania and Poland grew closer. Lithuania adopted Polish institutions of castellans and voivodes. Catholic Lithuanian nobles and church officials were granted equal rights with the Polish nobles and clergy. Forty-seven selected Lithuanian nobles were adopted by Polish families and granted Polish coats of arms. Thus the union signified the beginnings of the Polonization of Lithuanian culture and the rise of the Lithuanian nobility. It was one of the major steps towards the modernization and Europeanization of Lithuania. Historical background 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. In 1409, the second Samogitian uprising against the Teutonic Knights escalated into the Polish–Lithuanian–Teutonic War. Joint Polish–Lithuanian forces defeated the Knights in the decisive Battle of Grunwald in 1410. However, the war did not resolve all the disputes and by 1413 Poland–Lithuania was preparing for another war