The personal union between the Kingdom of Hungary and the Kingdom of Poland was achieved twice: under Louis I of Hungary in 1370 and under Vladislaus III of Poland in 1440.
The first union came about when the last Piast king of Poland, Casimir III, designated his sororal nephew, the Angevin king Louis I of Hungary, as his heir presumptive by the Privilege of Buda. Upon the death of Casimir, who left no legitimate sons, Louis ascended the Polish throne virtually unopposed. The Polish nobility welcomed his accession, rightly believing that Louis would be an absentee king who would not take much interest in Polish affairs. He sent his mother Elizabeth, sister of Casimir III, to govern Poland as regent. Louis probably considered himself first and foremost king of Hungary; he visited his northern kingdom three times and spent there a couple of months altogether. Negotiations with the Polish nobility frequently took place in Hungary. Hungarians themselves were unpopular in Poland, as was the king's Polish mother who governed the kingdom. In 1376, circa 160 Hungarians in her retinue were massacred in Kraków and the queen returned to Hungary disgraced. Louis replaced her with their relative, Vladislaus II of Opole.
During Romanticism, Hungarian historians portrayed the union as an annexation of Poland into Hungary. In 1845, Sándor Petőfi wrote that "the falling stars of the north, the east and the south were all extinguished in Hungarian seas". In reality, Poland's independence remained largely uncompromised. King Louis saw to it that Hungarian influence in Poland was not greater than Polish influence in Hungary.