The earliest settlement in the area was a Slavic stronghold at what is now known as the Cheb Castle complex, north of the town-centre. In 807 the district of today's Cheb was included in the new margraviate of East Franconia, which belonged at first to the Babenbergs, but from 906 to the margraves (marquis) of Vohburg. Depold II of Vohburg built the castle about which the town then grew. In 1179 town status was achieved. In 1149, by the marriage of Adelheid of Vohburg to the emperor Frederick I, Eger (Cheb) came into the possession of the House of Swabia, and remained in the hands of the emperors until the early 13th century, during which time it became an Imperial Free City.