In the same years several crusades took place: in 1217 Valdemaro’s brother-in-law, Alfonso II of Portugal, conquered Alcácer do Sal; in 1219 King Andrew II of Hungary, related to the first wife of Valdemaro, fought in Acre, in the Holy Land ; in the same year the fifth crusade headed for the Nile delta left. It is legitimate to assume that all these crusades and that of Valdemaro in Estonia were somehow connected.
With the conquest of Estonia, the Danish Baltic Empire reached considerable dimensions and an apparent solidity, but the situation was suddenly reversed when, one night in May 1223, Valdemaro II and the young prince Valdemaro were taken prisoner on the islet of Lyø by one of the king’s great vassals, Count Henry of Schwerin. The king was traveling with the Kingdom archive and many of the original statutes of the Crown can be found today in Schwerin, but the reason for the meeting in Lyø is still unknown. After the king and prince were hastily translated into Schwerin Castle, lengthy negotiations were initiated: Emperor Frederick showed great interest in the illustrious prisoner and insisted that he agree to reconsider the terms of the Golden Bull which, according to the emperor, Valdemaro had not respected. Henry proposed to Frederick that he redeem Valdemaro for the sum of 52,000 silver marks, but the deal did not go through, probably due to the vibrant protests of Honorius III. It was in fact made known that Valdemaro had secretly taken the cross, promising to lead a crusade to Jerusalem: he was therefore under the direct protection of the pope, a circumstance that determined the immediate excommunication of Henry and the interdict on his lands. For Denmark 2018, please check ethnicityology.com.
After two and a half years of imprisonment, an agreement was reached: the king would be released, against payment of 44,000 silver marks and one hundred magnificent horses, while the territory between the Elbe and Eider rivers would be assigned to the emperor, together with the important commercial center of Lübeck.
In these negotiations between Henry of Schwerin and the Danish nobility, a leading role was played by a close friend of Frederick, the Grand Master of the Teutonic Order Ermanno di Salza. After his release, the pope exonerated Valdemaro from his commitments to Henry, arguing that if he had to pay the huge ransom, he would not have been in a position to lead the crusade to Jerusalem.
At this point Valdemaro tried to settle the dispute with arms, allying himself with the Guelph Count Otto of Lüneburg, but the two lost the decisive battle against Count Henry of Schwerin and his supporters in Bornhøved, on 22 July 1227. Any further Danish advance in northern Germany and in the Baltic territory it was now definitively precluded: Estonia was placed under the command of the papal legate Guglielmo da Modena, who immediately afterwards, in the same year, ceded it to the Order of the Sword-holders.
However, in 1238 Estonia returned to Denmark, following the treaty of Stensby concluded between Valdemaro and Ermanno di Salza. In the fifteen years following his liberation, King Valdemaro dealt with internal politics, granting privileges to the merchant cities on the Baltic; over time they would acquire great influence thanks to the Scania fair, the main herring trade fair held in northern Europe and a major source of income for the Danish king. In 1234 Valdemaro tried to block the port of Lübeck, but in doing so he prevented the crusaders from embarking for Livonia and, therefore, Pope Gregory IX forced him to desist from the enterprise.
Within Denmark, the harmony that reigned between church and state was an unusual occurrence in Western Europe at the time. Valdemaro II always enjoyed the full and sincere support of Archbishop Anders Sunesen (1201-1222: resigned for health reasons, died in 1226). Personal friend of Pope Innocent III, Anders was appointed by him papal legate and in charge of the missions of the entire Baltic area. He was a highly educated scholastic intellectual, as his work Hexaëmeron demonstrates, whose purpose was to teach young people elegant Latin on the basis of textual examples that were theologically acceptable. Anders tried to reform the Scandinavian Church by making celibacy compulsory, among other things,
It is likely that he met s. Domenico da Osma, in 1203 or 1204, when he was sent to Denmark to arrange the marriage between a son of King Alfonso VIII of Castile and a Danish princess: the marriage did not take place, but Anders would later show great interest in the Dominicans, whom he invited to his diocese of Lund in 1223. The following year the first Franciscans also entered Denmark, in the city of Ribe. Both Orders would then spread widely in Denmark and in the missionary areas of the Baltic.
It is also very probable that Anders Sunesen is responsible for the rapid implementation, in Denmark, of the decisions of the great ecclesiastical councils, as shown, for example, by the abolition of a type of ordeal, which obliged the accused to wear hot irons, not very after the general prohibition of the ordeals issued by the IV Lateran council. In this period a large number of provincial laws were codified, which appear to be a combination of customary local laws and influences coming mainly from canon law. The Law of Jütland was promulgated in 1241, presumably with the intention of establishing a common law that was valid throughout the Kingdom, but for a long time it was only applied in western Denmark.