The Kingdom of Croatia (925-1102) emerged from the duchies formed by Croats, a Slavic people who settled the eastern Adriatic in the 7th century, partly under Avar rule. Christianized in the 9th century under Frankish and Byzantine influence, the Croats built an independent duchy under the Trpimirovic dynasty. Duke Branimir won papal recognition in 879, and his successor Tomislav, having defeated the Hungarians on the Drava and the Bulgarians on his southern frontier, was crowned, by tradition with a papal crown, as the first king of Croatia about 925. His realm stretched from the Adriatic islands and coastal cities of Dalmatia to the Pannonian plain.
The kingdom's position between powers shaped its history. Venice, Byzantium, Hungary and the Norman rulers of southern Italy all competed for the Dalmatian cities, which shifted allegiance as the balance moved. Under Peter Kresimir IV (1058-1074) the kingdom reached its greatest extent, holding the coastal towns with Byzantine consent and styling itself the kingdom of the Croats and Dalmatians. The church council of 1060 and 1075 aligned the Croatian church more closely with Rome, insisting on Latin liturgy over the old Slavonic rite, while the Glagolitic script survived in local use.
After the death of Dmitar Zvonimir in 1089 without a clear heir, succession disputes opened the door to outside intervention. The widow Helen, sister of the Hungarian king Ladislaus I, called in her brother, who occupied northern Croatia. The last native king, Peter Svacic, resisted in the mountains until he was defeated and killed, traditionally at Mount Gvozd in 1097. Croatian nobles then negotiated with Ladislaus' successor Coloman, and in 1102, in the settlement known as the Pacta Conventa, they recognized him as king.
The agreement of 1102 created a personal union: Croatia kept its own nobility, laws, diet (the Sabor) and administration under a ban, while sharing a king with Hungary, a link that endured, with interruptions, until 1918. Croatian history was thereafter shaped by Venice, which took most of the Dalmatian cities by 1420, by Hungary's weakness after the Mongol invasion, and from the 15th century by the Ottoman advance, which after Mohacs (1526) brought the Croatian crown to the Habsburgs. The medieval kingdom's memory, Tomislav's crown, the Trpimirovic state, and the Sabor, later anchored Croatian claims to statehood.