As per the legend, Lord Chandra, the moon got married to the 27 daughters of Daksha Prajapati. Out of the 27 wives he favoured only Rohni. This angered Daksha and he cursed the moon to lose his brightness.
The moon was very disturbed, he came down to Prabhas with his wife Rohini and both of them did penance before the Shiv linga at Somnath. Lord Shiva pleased with the worship, blessed the moon god to grow and shine with bright half.
Legend is that as the Shiv linga was worshipped by the moon hence Lord Shiva at this place is referred as Somnatha.