 The pirates did not have to contend with any central authority until the Alaouite Dynasty united Morocco in 1666.The latter attempted to establish control over the pirates, but failed.European and Muslim authorities continued to attempt to control the pirates over many years, but the Republic of Bou Regreg did not collapse until 1818.