The Danevirke was a system of earthworks and trenches that extended approximately 30 kilometers (18.6 miles) across much of the Jutland Peninsula in Denmark. For some time, scholars believed it had been built as a defense against southern attack; however, recent archaeological discoveries suggest its original purpose was to defend an important trading route that began in the North Sea and headed eastward.
The complex was initially built primarily of earth, with wooden support structures. Through dendrochronology, the earliest portion of the Danevirke has been dated to 737, suggesting that the first phase of construction began in the reign of Angantyr. A southern expansion was built during the reign of King Godfred (d. 810) that was believed to have had a gate in it; in 2010, archaeologists discovered that gate.
Although its original purpose may indeed have been to defend incoming ships loaded with Viking plunder as they headed eastward, the Danevirke was nonetheless used in defense against attack from the south -- though not always altogether successfully. In 934 King Henry I (the Fowler) invaded Denmark, broke through the Danevirke and made Schleswig part of Germany. As a result, King Harald Bluetooth extended and refortified the ramparts. Unfortunaely, Emperor Otto II successfully stormed it in 974. Little more was done to it until the 12th century, when King Valdemar the Great ordered parts of it to be rebuilt in brick as part of his plan to defend against Slavic and German invasion.
In the 15th century, Schleswig and Holstein were united as part of Denmark, and the need for a defense lessened. The Danevirke slipped into decay. For the next 350 years or so it was abandoned and ignored, until the Danes faced invasion by the Prussians in 1848. They strengthened the fortifications, but the German artillery was too effective, and the invaders broke through. It was fortified again in the 1850s, and it was generally considered impossible to breach; but the technology of warfare had advanced, and when in 1864 Prussians invaded once again, the Danes abandoned the Danevirke. At this point the fortifications were destroyed by the invaders.
Though no longer a viable defense system, the Danevirke was still evident in a long line of impressive ruins. In 1900, excavation of those ruins began, and it has proceeded off an on until the present day. Fascinating runes have been found, and more recent explorations have revealed the complex to be larger and older than originally believed.