Gemstone can be forms and deposits in many different ways:
Magmatic Crystallization: Some gems like Diamond, Moonstone, Corundum and Topaz are occur in Magma in crystal form. Crystal forms in deep depth which brought to the top surface by lava with magma in volcanic blowup blast.
Pegmatite: Topaz, Beryl, Tourmaline, Quartz and Spodumene are forms through magmatic crystallization. In this formation, a silicate by squeezing into surrounding rocks which produces pegmatites. Pegmatites contain large gem crystals.
Hydrothermal vein deposits: After magma crystallization, kinds of hydrothermal solution which consists of many chemicals. Silicate remains this solution. This solution is extremely hot. It cracks in surrounding rocks and consists in Veins Emerald, Red Beryl and Topaz.
Placer or Alluvial deposits: Minerals are resistance to weather and decomposite. Through flowing water in river Diamond, ruby, sapphire, chrysoberyl, zircon, garnet, quartzs are found.
Metamorphic deposits: When a rock is subjected to high temperature and pressure, the chemical components of its constituent minerals get re-arranged into new minerals. Metamorphic rocks are rocks changed by heat, pressure, and interaction with solutions.
Plate tectonics produce Jade. In rare conditions of very high pressure and heat, Diamond can also occur.
Regionally metamorphosed rocks: Garnet and cordierite form in these rocks.
Chemical precipitates: Malachite, opal, rhodochrosite and turquoise are result of physicochemical environment changes, chemical containing aluminum and phosphorous.