The Klaipėda Castle was first mentioned in a 1252 document in which Grand Master Eberhard von Zeine agreed with Bishop Heinrich of Courland to build a castle between the Nemunas and Danė rivers. The city began to develop after a wooden castle was built on the Southern Horn of the Danė River. It was believed that the lagoon was a branch of the Nemunas River, called Memel in Germany; hence, the castle was named Memelburg. The wooden castle was built in a marshy area, so in 1253 a stone enclosure-type castle was constructed on the right bank of the Danė River. The courtyard contained stone and wooden buildings, and the walls were protected by moats and ramparts. In the 14th and 15th centuries,
the Klaipėda Castle had to withstand numerous attacks from the Samogitians and Lithuanians, leading to frequent burning and rebuilding. By the 15th century, the Klaipėda Castle had been fortified to withstand firearms. Its defensive system consisted of towers, defensive walls, moats, and ramparts with defensive structures. In the 17th century, the castle was attacked by the Swedes and damaged by several fires, necessitating further reconstruction and enhancement of its defenses. In 1686, the earth ramparts around Klaipėda Castle were rebuilt into bastions. The final fortification works of the Klaipėda Castle and the city took place during the Seven Years' War (1756-1763).