An Istrian margraviate itself first emerged following the death of Duke Eric of Friuli in the 799 Siege of Trsat on the Frankish border with Littoral Croatia. Istria was enfeoffed to the Frankish count Hunfrid, who also bore the title of a dux Foroiulanus. The original Carolingian march stretched from the Julian Alps and the Kras Plateau down to the Gulf of Kvarner. It was one of three marches, along with Friuli and Carantania, guarding Italy from the Avars, Slavs, and Magyars successively. In the first decade of the 9th century, Istria was ruled by one Duke John, nominally according to its ancient Byzantine customs, but in fact as a Frankish vassal. The region then had nine cities, Trieste foremost among them.