We people. in Pakistan constantly read about Mahmud Ghaznavi as a great Mujahid and his act of invasion and destruction of the temple of Somnath is mentioned as a highly commendable act.
What is the Islamic position of this act? Was it justifiable? Some people justify by drawing it parallel to the destruction of the statues in the Kaa'ba by the Prophet (P.B.U.H.). Is it correct?
I know you are busy but please a response will be most appreciated.
First of all, we should be quite clear that the Prophet's destruction of the statues placed in the Ka`bah was a part of the law relating to the messengers of God and, therefore, analogies cannot be drawn from the cleansing of the Ka`bah at the hands of the Prophet (pbuh) for anyone else. For more details on this topic, please refer to one of my earlier responses to a related question titled "Rafi Usmani's Opinion regarding the Destruction of Buddha Statues".
As for the Sultan's destruction of the temple of Somnath, it is presented by various historians from their own different perspectives. However, keeping in mind the fact that the Sultan did not generally destroy any places of worship during his invasions, it seems quite plausible that the Somnath was destroyed not for religious reasons, but as a punishment implemented upon the residents of the place. According to the Islamic Encyclopedia, published by the University of the Punjab, giving one of the variant explanations of the Sultan's action says that the Sultan was, in fact, going towards Kanth Kot - where the Raja of Gujrat had taken refuge - but the people of Somnath refused to allow passage to the Sultan. It was because of this reason that the Sultan punished them and destroyed their revered temple. Another plausible explanation is that the Sultan ordered the destruction of the Temple only after the people of the area refused to give him the agreed upon war booty and buried their possessions in the Temple. Other historians, however, have given alternative reasons for the Sultan's destruction of the temple.
The important thing that one needs to keep in mind is that the actions of the Sultan may or may not be considered as in keeping with the directives and recommendations of Islam. It is not the Sultan's actions that would determine the directives and recommendations of Islam, but, on the contrary, to be considered as 'correct', the Sultan's actions should be seen in the light of the directives of the Qur'an and the Sunnah of the Prophet (pbuh).
I hope this helps.
June 9, 2002
 For details, see "Urdu Dairah Ma`arif e Islamiyyah", Danishgah Punjab, Lahore, First Edition, Volume 20, Page 49.
Answer published by Moiz Amjad