The castle was built on the basis of a treaty between Riga and the Livonian Order – in the 13th century Rigans had rebelled against the Order and demolished its original castle in the centre of the town.
Due to constant conflict with Rigans the Order chose to build a new castle beyond the borders of the town rather than to rebuild the original castle.
The site occupied by Convent of the Saint Spirit – a hospital and shelter for the poor – was chosen and the convent moved to the location of the original castle.
The castle served as the residence of the Master of the Livonian Order, but due to continuous conflicts with Rigans the residence was moved to Castle of Cēsis sometime before the castle was destroyed by Rigans in 1484.
The Rigans eventually lost the fight and were forced to rebuild the castle – the restoration was finished in 1515.
After the Treaty of Vilnius order ceased to exist in 1561 the Castle became Lithuanian and in 1569 - Polish-Lithuanian stronghold.
In 1621 Riga came under Swedish rule and the Castle was used to house Swedish administration.

After the city came under the Russian Empire in the early 18th century, the castle housed administration and courts of Riga Governorate (which included most of present Latvia and Estonia) and served as residence of Governors General.

Since 1922 the castle became residence of the President of Latvia.
After Soviet occupation the castle housed Council of People Commissars of Latvian SSR in 1940–1941.
In 1941 the Young Pioneer organization of the Soviet Union moved into northern part of the castle, which therefore became known as the Pioneer Castle.

Several museums are housed in the southern part of the castle.
After the independence of Latvia was restored the northern part of the Castle again became the residence of the President of Latvia.
The castle was built on the basis of a treaty between Riga and the Livonian Order – in the 13th century Rigans had rebelled against the Order and demolished its original castle in the centre of the town. Due to constant conflict with Rigans the Order chose to build a new castle beyond the borders of the town rather than to rebuild the original castle. The site occupied by Convent of the Saint Spirit – a hospital and shelter for the poor – was chosen and the convent moved to the location of the original castle. The castle served as the residence of the Master of the Livonian Order, but due to continuous conflicts with Rigans the residence was moved to Castle of Cēsis sometime before the castle was destroyed by Rigans in 1484. The Rigans eventually lost the fight and were forced to rebuild the castle – the restoration was finished in 1515. After the Treaty of Vilnius order ceased to exist in 1561 the Castle became Lithuanian and in 1569 - Polish-Lithuanian stronghold. In 1621 Riga came under Swedish rule and the Castle was used to house Swedish administration.
After the city came under the Russian Empire in the early 18th century, the castle housed administration and courts of Riga Governorate (which included most of present Latvia and Estonia) and served as residence of Governors General.
Since 1922 the castle became residence of the President of Latvia. After Soviet occupation the castle housed Council of People Commissars of Latvian SSR in 1940–1941. In 1941 the Young Pioneer organization of the Soviet Union moved into northern part of the castle, which therefore became known as the Pioneer Castle. 
Several museums are housed in the southern part of the castle. After the independence of Latvia was restored the northern part of the Castle again became the residence of the President of Latvia.
Riga Castle