Following the collapse of the Roman Empire, Flanders became part of the Merovingian realm of Neustria. In the 9th century it became part of West Francia, forming a "pagus" within the kingdom of Charles the Bald. In 864, Cassel passed into the hands of Baldwin Ironarm, who expanded his holdings to become the first count of the County of Flanders. At the time, the town was on the edge of a deep bay of the North Sea, making it vulnerable to raids by the Vikings, who attacked and destroyed it in the 9th century. It was rebuilt by Baldwin's grandson, Arnulf I, in the 10th century.