The castle again fell to Denmark just ten years later, in 1237, but was sold to the Teutonic Order in 1346, and would remain in their hands for the remainder of the Middle Ages.
[1] After the Protestant Reformation and many wars that followed in the 16th century, the Teutonic Order lost its last possessions in Estonia and the region became contested by Sweden, Poland and Muscovy (Russia).
Subsequently a number of larger reconstruction schemes were carried out and the building complex was effectively turned from a castle into a palace.
A new dominating wing in Baroque and Neoclassical style, designed by Johann Schultz, was added in the eastern part of the complex.
The castle and the building of Riigikogu were however used by the local Supreme Soviet, the formal rubber stamp legislative body of Soviet-occupied Estonia without any substantive meaning, between 1947 and 1990.
According to a legend, recorded in the 19th century, the entire hill of Toompea was once upon a time created by a mythological heroine Linda who built it boulder-by-boulder with her own hands.