It was founded by Idris ibn Salih, Emir of the medieval Kingdom of Nekor, between 749 and 761 AD. His son Sa'id I ibn Idris moved the capital to Nekor from Temsaman. Nekor was sacked by the Vikings sometime between 859 and 862 AD, and destroyed by the Almoravid Yusuf ibn Tashfin in 1080 during his conquest of the Rif.