 In the mid-10th century it experienced the last period of splendour under count Oberto I, who was lord of the whole Ligurian Mark, and momentarily repulsed the pirate threat.However, in the 990s the situation worsened again, and the episcopal see was moved, first to Carrara then, definitively, to Sarzana in 1207 (or 1204).In 1015 Luna was conquered by the Andalusian emir of Denia, Mujāhid with his Sardinian ships