After the death of Algirdas in 1377, Andrei, as the eldest son, rivaled his half-brother Jogaila, whom Algirdas had designated as his heir. Jogaila at the time enjoyed strong support from his uncle Kęstutis. Andrei organized an anti-Lithuanian coalition with Polotsk, Grand Duchy of Moscow, and the Livonian Order. In 1379, Moscow's army attacked eastern territories of the Grand Duchy; Moscow and Lithuania were at peace since the Treaty of Lyubutsk in 1372. Andrei's brother Dymitr I Starszy did not defend the Principality of Trubetsk and Starodub. However, the Russian army did not remain in taken territories and retreated back to Moscow; Andrei and Dymitr followed it. Jogaila signed a ten-year truce with the Teutonic Knights on September 29, 1379 and a truce with the Livonian Order on February 27, 1380, thus fracturing the coalition. He further enlisted Mamai, a powerful warlord of the Golden Horde, and Oleg II of Ryazan as his allies against Andrei. In 1380, Andrei and Dymitr fought for Moscow in the Battle of Kulikovo against the Tatars. The Tatars were badly defeated when Jogaila's army did not arrive to the battlefield on time.