In 1239, after the Mongol invasion of Rus, the Principality of Trubetsk passed to the Princes of Bryansk, and then to the Princes of Trubetsk. In 1566 Ivan IV the Terrible took the principality during the Livonian War. In 1609 Vasili IV of Russia relinquished it to the Polish–Lithuanian Commonwealth during the Polish–Muscovite War (1605–1618). In 1654 Prince Aleksey Trubetskoy on the side of Alexis I of Russia led the southern flank of the Muscovian army from Bryansk to Ukraine. The territory between the Dniepr and Berezyna was overrun quickly, with Aleksey Trubetskoy taking Mstsislaw (Mstislavl) and Roslavl. In 1654 The Principality of Trubetsk was finally conquered by Aleksey Trubetskoy, Prince of Trubetsk himself, as a result of the Russo-Polish War (1654-1667).