In 1454 after the outbreak of the Thirteen Years' War, troops from Danzig (Gdańsk) occupied Lauenburg and Bütow (Bytów); the following year they were turned over to Eric II, Duke of Pomerania, to form an alliance. Because Lauenburg remained loyal to the Prussian Confederation and not the Teutonic Order, King Casimir IV Jagiellon of Poland granted the town three nearby villages. Troops from the Polish-allied city of Gdańsk (Danzig) reoccupied Lauenburg in 1459 when the mayor, Lorenz Senftopf, entered into negotiations with the Teutonic Knights. Eric replaced the Danzigers with Teutonic Knights the following year, however, when he switched sides during the war. After the Teutonic Knights were ultimately defeated in the Thirteen Years' War, Lębork passed to Poland, according to the 1466 Second Peace of Thorn, and was granted by Casimir IV Jagiellon to Eric and his Pomeranian successors as part of the Lauenburg and Bütow Land, a Polish fief.