The glory and riches of the temple were so much that it caught the attention of many kings who attacked the temple and demolished it. This included the old ruler of Sindh and Mughal Emperor, Aurangzeb.
However, the most notable of these looters was Mahmud Ghazni, who attacked the Somnath temple 17 times, and every time, took away its wealth.
Mahmud of Ghazni was a Turkish invader who attacked India 17 times between 1000 and 1024 AD for the dual purposes for accumulating wealth and spreading Islam. In 1024 AD, he raided Gujarat and took away all the wealth of the Somnath temple, damaging it severely.
However, each time it was demolished, the devotees of Lord Shiva worked hard and restored the temple to its original glory.