The earliest written record of Trelleborg is from 1257, when Trelleborg was presented as a wedding gift from the Danish royal family to the Swedish Prince Valdemar. It was soon reconquered by the Danes, and it belonged to Denmark until 1658, when Scania was lost to Sweden by the Treaty of Roskilde.
In medieval times, Trelleborg had an important part in herring fishing. At that time, this was conducted along the entire coast line of what is now Sweden, as the herring shoals were of such great numbers that fishermen were said to have been able to stand on the shore and land fish with nets. Trelleborg became an important merchant city as merchants from Germany came to trade herring. In 1619 following a devastating fire, the Danish King decided that one merchant city on the coast was sufficient and revoked Trelleborg's status as a merchant city in order to favour Malmö.
Not until 1840 was Trelleborg allowed to become a merchant city, and not until 1867 did it regain its rights as a city of Sweden. Mostly this was thanks to the work of a few stubborn men, who had continuously been petitioning the Swedish Riksdag with these requests since 1658. The local government reform of 1971 made Trelleborg the seat of Trelleborg Municipality, covering both rural and urban areas