Khalid ibn Hamid al-Zanati (?–?) was a Zenata Berber chieftain and military commander during the Berber Revolt of the 740s against the Umayyads in the Maghreb.
For reasons which are still obscure, Maysara al-Matghari, the original leader of the Berber Revolt and self-proclaimed caliph, was deposed and executed by fellow Berber rebels in the Summer or Fall of 740. Khalid ibn Hamid, a respected Zenata chieftain, was elected to take his place.
Khalid ibn Hamid led the Berber rebel armies in two stunning victories over the Umayyad authorities. In the Battle of the Nobles in late 740, Khalid annihilated a vanguard Arab army, composed of the aristocratic Arab cavalry elite of Ifriqiya. The shock of the defeat prompted the Umayyad Caliph Hisham to dispatch a mighty Syrian expeditionary force from the east to join the Ifriqiyans in crushing the Berber rebellion. In October 741, Khalid's Berber army defeated the combined Ifriqiyan-Syrian force at the Battle of Bagdoura (or Baqdura), by the Sebou River (near modern Fes), killing the new Ifriqyian governor Kulthum ibn Iyad al-Qasi, in the process.
Khalid ibn Hamid disappears from the chronicles soon after this. The Berber revolt continued for a little while longer, but under different commanders.
But while his fate is uncertain, his legacy is not. Khalid ibn Hamid's victories permanently broke the Umayyad hold on the western Maghreb. As a result, Morocco would spin off into an independent future, and never again come under the rule of an eastern caliphate.