half of the fourteenth century (1300–1350) Visby was at the height of its wealth and influence, and it was during this time that Laws of Wisbuy, a set of maritime laws that had broad influence in the Baltic and beyond, were probably promulgated. In 1361, Gotland was conquered by Valdemar IV of Denmark. 1,800 Gotlanders were killed in battle in front of the city. Valdemar tore down part of the wall, set up three huge beer barrels and threatened to turn his men loose to pillage the town unless they were filled with silver and gold. The Visby city fathers fulfilled the demand, with churches stripped of their valuables. Valdemar added "King of Gotland" to his title list. His treatment of Visby, a member of the Hanseatic League, precipitated that League into war with Denmark; however, though Valdemar was forced into various concessions, he retained Visby as a Danish city. In 1391, 1394 and 1398, it was taken and plundered by the Victual Brothers, pirates who sailed the Baltic Sea. An invading army of Teutonic Knights conquered Gotland in 1398, destroyed Visby and expelled the Victual Brothers. In 1409, Grand Master Ulrich von Jungingen of the Teutonic Knights guaranteed peace with the Kalmar Union of Scandinavia by selling the island of Gotland to Queen Margaret of Denmark, Norway and Sweden. In 1411, the Norwegian, Danish and Swedish King Eric of Pomerania had the castle of Visborg constructed, and settled himself there for twelve years, during which the city virtually became a pirates' nest, and the commerce halted. As of 1470, the Hanseatic League rescinded Visby's status as a Hanseatic town. In 1525, the final blow came. In the Danish throne quarrel, Lübeck, a Free City of the Holy Roman Empire and a leading member of the Hanseatic League, supported Frederick I, while Søren Norby the Danish governor of Gotland fought for Christian II, even after Christian's official resignation in 1523. While Norby fought a military action in Sweden, the Lübeckers successfully attacked Visby and set the city on fire from four sites. But unlike widespread belief, several churches survived at first. The churches of St. James (which already had been closed before), St. Nicholas and St. Gertrude were sacked by Lübeck's army. With the reformation, all churches except St. John, which became the city parish, were closed. In 1528, the citizens of Visby sacked the church of the Holy Trinity,