There are several legends regarding Gemstones. If Rudraksha Beads have originated from Lord Shiva, the gemstones are considered to be originated from Lord MahaVishnu.
The Demon King Bali was a very strong that he even defeated the Lord Indra. King Bali was also a generous King and people in his kingdom were very happy. The Gods troubled by the defeat approaches Lord Maha Vishnu and asks him to save them. Maha Vishnu takes the form of a small Brahmin and goes to King Bali and asks him for 3 1/2 feets of land which
Bali readily agrees. Lord Maha Vishnu then assumes his Virad form and with three feet’s he measures the entire world and still 1/2 feet was remaining and Vishnu asked where to keep it. Vishnu completes the rest of the 1/2 feet by placing his feet on the Demon Kings Chest. The area where his feet touched on the Kings Body turned into gems. The different parts of the body turned into different gems like diamond from head, pearl from mind etc. Totally 84 precious and semi precious gemstones came into existence from the body of King Bali. After that Indra used his Vajra and broke the body into pieces. Later Lord Shiva wore 9 of this gems on his trishul representing the 9 planets and 12 zodiacs and threw the different parts of the body in different places on the earth becoming mines.