of native troops, Cossacks and Tatars instead of a few thousand skilled troops and mercenaries, as was the practice of his adversaries. Ivan's campaign reached its height in 1576 when another 30,000 Russian soldiers crossed into Livonia in 1577 and devastated Danish areas in retaliation for the Danish acquisition of Hapsal, Leal, and Lode. Danish influence in Livonia ceased, as Frederick accepted deals with Sweden and Poland to end nominal Danish involvement. Swedish forces were besieged in Reval (Tallinn) and central Livonia raided as far as Dünaburg (Daugavpils), formally under Polish–Lithuanian control since the 1561 Treaty of Vilnius. The conquered territories submitted to Ivan or his vassal, Magnus, declared monarch of the Kingdom of Livonia in 1570. Magnus defected from Ivan IV during the same year, having started to appropriate castles without consulting the Tsar. When Kokenhusen (Koknese) submitted to Magnus to avoid fighting Ivan IV's army, the Tsar sacked the town and executed its German commanders. The campaign then focussed on Wenden (Cēsis, Võnnu), "the heart of Livonia", which as the former capital of the Livonian Order was not only of strategic importance, but also symbolic of Livonia itself. 1577–1583: Defeat of Russia Swedish and Polish–Lithuanian alliance and counter-offensives In 1576, the Transylvanian prince Stefan Batory became King of Poland and Grand Duke of Lithuania after a contested election to the joint Polish–Lithuanian throne with the Habsburg Emperor Maximilian II. Both Batory's fiancée Anna Jagiellon and Maximilian II had been proclaimed elected to the same throne in December 1575, three days apart; Maximilan's death in October 1576 prevented the conflict from escalating. Batory, ambitious to expel Ivan IV from Livonia, was constrained by the opposition of Danzig (Gdansk), which resisted Batory's accession with Danish support. The ensuing Danzig War of 1577 ended when Batory conceded further autonomous rights to the city in return for a payment of 200,000 zlotys. For a further 200,000 zloty payment, he appointed Hohenzollern George Frederick as administrator of Prussia and secured the latter's military support in the planned campaign against Russia. Batory received only few soldiers from his Polish vassals and was forced to recruit mercenaries, primarily Poles, Hungarians, Bohemians, Germans, and Wallachians. A separate Szekler brigade fought in Livonia. Swedish King John III and Stefan Batory allied against Ivan IV in December 1577, despite problems caused by the death of Sigismund which meant that the issue of the substantial inheritance due to John's