Like other Estonian towns, Haapsalu has changed hands many times since its founding centuries ago. The German Knights of the Sword conquered this region in 1224, and Haapsalu became the bishop's residence, with a fortress and cathedral built soon afterwards. The Danes took control during the Livonian War (around 1559), then the Swedish had their turn in the 17th century, but they lost it to the Russians during the Great (but brutal) Northern War in the 18th century.
The city flourished under the tsars, mostly because of mud. Once the curative properties of its shoreline were discovered in the 19th century, Haapsalu transformed into a spa centre. The Russian composer Tchaikovsky and members of the Russian imperial family visited the city for mud baths. A railway that went all the way to St Petersburg was completed in 1907 with a 214m-long covered platform, then said to be the longest in the Russian Empire. Visitors can still admire the colourfully designed station with its wooden lace ornamentation and grand colonnade, though now only buses run from this station.