By the end of the 13th century the Kingdom went into a heavy conflict with Lithuania, Poland, and Hungary with partial successes and failures. Upon the death of Lev I of Galicia the whole Kingdom went into decline due to a civil war. In 1323 the fall of the Polish-Ruthenian coalition against the Lithuanians the local boyars installed Boleslaw-Yuri II of Galicia. That move only strained the Ruthenian-Polish relationships which after short conflict ended the sovereignty of the Ruthenian Kingdom and the Halych Principality was annexed to the Kingdom of Poland in 1349. The partition of the Ruthenian Kingdom ensued the Galicia–Volhynia Wars as both Lithuania and Polish states fought for their expansion east. The new town of Halych was soon re-established in close proximity to the bishop's residence, receiving its Magdeburg Rights in 1367. Later its new castle was built sometime in the 16th century. By this time the area of the modern Halych Raion lost its importance and the town of Halych has become as any other small Polish towns.