Like other Estonian towns, Haapsalu has changed hands many times since its founding. 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 Swedes had their turn in the 17th century, but they lost it to the Russians during the Great 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. In Soviet times, Haapsulu was closed to foreigners.