Throughout the existence of medieval Livonia there was a constant struggle over supremacy, between the lands ruled by the Church, the Order, the secular German nobility, and the citizens of the Hanseatic towns of Riga and Reval.
[13] At the start of the 13th century, German crusaders from Gotland and the northern Holy Roman Empire conquered the Livonian and Latgallian lands along the Daugava and Gauja rivers.
In 1218 Pope Honorius III gave Valdemar II of Denmark free rein to annex as much land as he could conquer in Estonia.
[14] This division of medieval Livonia was created by Papal Legate William of Modena in 1228[14] as a compromise between the church and the Livonian Brothers of the Sword, both factions led by Germans, after the German knights had conquered and subdued the territories of several indigenous tribes: Finnic-speaking Estonians and Livs, and Baltic-speaking Latgalians, Selonians, Semigallians and Curonians.
[citation needed] Medieval Livonia was intermittently ruled first by the Brothers of the Sword, since 1237 by the semi-autonomous branch of Teutonic knights called Livonian Order and the Roman Catholic Church.
By the mid 14th century, after buying the Duchy of Estonia from Christopher II, the Livonian Order controlled about 67,000 square kilometers of the Old Livonia and the Church about 41,000 km2 (16,000 sq mi).
Two major civil wars were fought in 1296–1330, 1313–1330, and in 1343–1345 the Estonian revolt resulted in the annexation of the Danish Duchy of Estonia within the Teutonic Ordensstaat.
[17] In the beginning of the 14th century Denmark was no longer a powerful state and the local German nobility had effectively become the rulers of the territory.
The Livonian Order managed to maintain an independent existence, as it did not participate in the battle and suffered no casualties, having obtained a truce with Grand Duke Vytautas.
The Livonian confederation agreement (eiine fruntliche eyntracht) was signed in Walk on 4 December 1435, by the archbishop of Riga, the bishops of Courland, Dorpat, Ösel-Wiek and Reval; the representatives of the Livonian Order and vassals, and the deputies of Riga, Reval and Dorpat city municipal councils.
In 1559, the Bishop of Ösel-Wiek and Courland Johannes V von Münchhausen (1542–1560) sold his lands to King Frederick II of Denmark for 30,000 thalers.
The Danish king gave the territory to his younger brother Duke Magnus of Holstein who in 1560 landed with an army on Ösel.
[28][29]According to Henry of Livonia, Bishop Albert of Riga emphasized to Pope Innocent III the importance of his see as a crusading venue and its association with Mary, the Mother of Jesus when reporting to the Fourth Lateran Council in 1215: "Sicut", inquit, "pater sancte, terram sanctam Ierosolimitanum, que est terra filii, sanctitatis tue studio fovere non desinis, sic Lyvoniam, que est terra matris, [...] derelinquere non debes."