Somnath is about 5km from Veraval and had a checkered history. It is believed that the Somnath temple here was originally built by Somraj, the Moon God himself, out of gold, and then rebuilt by Ravana in silver and then by Krishna in Wood, then by Bhimdev in stone. Somnath is also known by several other names -- Deo pattan, Prabhas Pattan or Pattan Somnath, which it acquired during its long and eventful history. Somnath was once the most revered shrine in the country, for it had one of the twelve pre-eminent Jyotirlingas (the glowing Lingas), which held a special significance for the Hindus. Somnath's glory and fame are legendary. It is said that people from the remotest parts of the country came to worship at the shrine; revenues collected from ten thousand villages was spent on the maintenance of the temple. Two thousand Brahmins (priests) served the idol and a golden chain attached to a huge bell plate announced the commencement of prayers.
Somnath rose and fell many a time and the amazing drama of the iconoclast's zeal for its desecration and the devout Hindu's passionate desire for its restoration continued till the 15th century, when the Hindus finally gave up in sheer despair and built a new temple nearby.
Northern India had ceased to attract Mahmud, for the spoils of its most wealthy temples were already in his treasury. But the rich and prosperous province of Gujarat was still untouched, and on October 18, 1025, he started from Ghazni with his regular troops and thirty thousand volunteer-horsemen for the temple of Somnath, situated at the distance of a bow-shot from the mouth of the Saraswati, by the side of which the earthly body of Lord Krishna had breathed its last.
Ghazni Mohammed descended on Somnath in 1024 when the temple was so prosperous that it has 300 musicians, 500 dancing girls and 300 barbers to shave the heads of visiting pilgrims. There is a description to this effect by Al Biruni, an Arab traveller. After a two-day battle, Ghazni Mohammed carted off its fabulous wealth and also destroyed the temple, thus setting a precedent of Muslims destroying the temple and Hindus rebuilding it, for it was razed again in 1297, 1394 and finally in 1706 by Aurangzeb, the Mughal emperor who was notorious for such acts.
Mahmud entered the temple and possessed himself of its fabulous wealth. `Not a hundredth part of the gold and precious stones he obtained from Somnath were to be found in the treasury of any king of Hindustan.' Later historians have related how Mahmud refused the enormous ransom offered by the Brahmans, and preferred the title of `Idol-breaker’ (But-shikan) to that of `Idol-seller' (But-farosh). He struck the idol with his mace and his piety was instantly rewarded by the precious stones that came out of its belly. This is an impossible story. Apart from the fact that it lacks all contemporary confirmation, the Somnath idol was a solid unsculptured linga, not a statue, and stones could not have come out of its belly. That the idol was broken is unfortunately true enough, but the offer of the Brahmans, and Mahmud's rejection of the offer, is a fable of later days. The temple, which stands today, was built in the traditional pattern on the original site by the sea, thanks to the efforts of Sardar Vallabhbhai Patel.