It has long been recognised that the system of burhs recorded in the Burghal Hidage was the creation of King Alfred, the received view being that they were in place by the time of the second Viking invasions in the 890s (based on the evidence in the "Anglo-Saxon Chronicle" of the existence of garrisons in many of them by this time), and that most of them were constructed in the 880s. However, the fact that nearly half the number of hides in the system were allocated to burhs on the northern border of Wessex with Mercia suggests a context for the creation of this system in the period when Mercia was occupied and controlled by the Vikings. This was the situation in the period from 874, when the Vikings at Repton installed Ceolwulf (II) as king of Mercia to replace Burgred. The most probable context on strategic grounds is in the short period between 877 and 879, when Mercia was partitioned between Ceolwulf and Guthrum. The creation of this system by King Alfred can therefore best be seen as both an in-depth defence of Wessex against possible invasion of Viking forces (such as indeed happened in the period 875-early 878), and as a strategic offensive against the Vikings who controlled Mercia and London at that time.