The history of Latvia began around 9000 BC with the end of the last glacial period in northern Europe. Ancient Baltic peoples arrived in the area during the second millennium BC, and four distinct tribal realms in Latvia's territory were identifiable towards the end of the first millennium AD. Latvia's principal river Daugava, was at the head of an important trade route from the Baltic region through Russia into southern Europe and the Middle East that was used by the Vikings and later Nordic and German traders.
In the early medieval period, the region's peoples resisted Christianisation and became subject to attack in the Northern Crusades. Latvia's capital city Riga, founded in 1201 by Germans at the mouth of the Daugava, became a strategic base in a papally-sanctioned conquest of the area by the Livonian Brothers of the Sword. It was to be the first major city of the southern Baltic and, after 1282, a principal trading centre in the Hanseatic League.