The Barghawatas (also Barghwata or Berghouata) were a Berber tribal confederation on the Atlantic coast of Morocco, belonging to the Masmuda confederacy. After allying with the Sufri Kharijite rebellion in Morocco against the Umayyad Caliphate, they established an independent state (AD 744-1058) in the area of Tamesna on the Atlantic coast between Safi and Salé under the leadership of Tarif al-Matghari. Some historians believe that the term Barghawata is a phonetic deformation of the term Barbati, a nickname which Tarif carried. It is thought that he was born in the area of Barbate, near Cádiz in Spain. However, Jérôme Carcopino and other historians think the name is much older and the tribe is the same as that which the Romans called Baquates, who up until the 7th century lived near Volubilis. Few details are known about Barghawata. Most of the historical sources are largely posterior to their rule and often present a contradictory and confused historical context. However, one tradition appears more interesting. It comes from Córdoba in Spain and its author is the Large Prior of Barghawata and the Barghawata ambassador to Córdoba Abu Salih Zammur, around the middle of the 10th century. This tradition is regarded as most detailed concerning Barghwata. It was reported by Al Bakri, Ibn Hazm and Ibn Khaldun, although their interpretations comprise some divergent points of view. The Barghawatas, along with the Ghomara and the Miknasa, launched the Berber Revolt of 739 or 740. They were fired up by Sufri Kharijite preachers, a Muslim sect that embraced a doctrine representing total egalitarianism in opposition to the aristocracy of the Quraysh which had grown more pronounced under the Umayyad Caliphate. The rebels elected Maysara al-Matghari to lead their revolt, and successfully seized control of nearly all of what is now Morocco, inspiring further rebellions in the Maghreb and al-Andalus. At the Battle of Bagdoura, the rebels annihilated a particularly strong army dispatched by the Umayyad caliph from Syria.