According to a legend, the entire hill of Toompea was made by Linda who built it boulder-by-boulder with her own hands. One reason for the birth of this legend is probably that settlers during the time of ancient Estonia made use of the natural hill as an easily defended stronghold. Over time, the place also developed into a commercial hub. It was probably one of the first inhabited areas of what later became Tallinn. In 1219, the castle was taken over by Danishcrusaders led by Valdemar II. According to a popular Danish legend, the flag of Denmark fell from the sky during a critical stage of the battle. This first proper castle was referred to as the "Castle of the Danes", in LatinCastrum Danorum and in Estonian Taanilinnus. From the latter, the modern name of the city of Tallinn is possibly derived. In 1227, the castle was taken over by the Order of the Brethren of the Sword, who initiated rebuilding schemes. The castle they started building is to a large extent the castle that is visible today. The castle again fell to the Danes just ten years later, but was sold to the Teutonic Order in 1346, and would remain in their hands for the remainder of the Middle Ages. As the crusading Teutonic Order was a religious order, the castle came to resemble a monastery in several ways. It included a chapel, a chapter house and a dormitory for the knights. The order was also responsible for erecting the still visible towers of the church, including "Pilsticker", "Stür den Kerl", "Landskrone" and the probably most famous, "Pikk Hermann", ("Langer Hermann" or "Tall Hermann". Tall Hermann is tall and dominates the castle skyline. The flag of Estonia is hoisted at the top of the tower every day at sunrise, to the sound ofthe national anthem, and lowered at sunset. With the upheavals of the Livonian War during the 16th century, the crusader orders formerly dominating the present-day Baltic states were dissolved and the region became contested by Sweden, Poland and Russia. By 1561, northern Estonia had become a Swedish dominion. The Swedes transformed the castle from a crusaders' fortress into a ceremonial and administrative centre of political power in Estonia, a purpose the castle has served ever since. In 1710, Sweden lost the territory of modern-day Estonia to the Russian Empire. The Russian administration eventually carried out large reconstruction schemes and turned the castle definitively into a palace. A new dominating wing in Baroque and Neoclassical style, designed by Johann Schultz, was added in the eastern part of the castle complex. It housed the administration of the Governorate and the living quarters of the governor. During the czarist era, a public park was also laid out to the south-east of the castle, and an archive building erected nearby.
Parliament building
Following the Estonian Declaration of Independence in 1918, a building to house the parliament of the republic was erected at the site of the former convent building of the Teutonic Order. Taking two years to complete, it was finished in 1922, and designed by architects Eugen Habermann and Herbert Johanson. Although its exterior is traditionalist, the interior is Expressionist in style - the world's only Expressionist parliament building. During the subsequent periods of Soviet, German, and a second Soviet occupation the Riigikogu was disbanded. The castle and the building of the Riigikogu were however used by the Supreme Soviet of the Estonian SSR during the second Soviet occupation.