How to reduce cramping in hands (mountain biking)?
Your question suggests that you might hold your handle bars too tight.


A tense grip over a long tube leads inevitably to cramps.


If you are not going over technical terrain or going very fast it is usually safe to change grips and hold bars much more loosely. With experience you will develop a firm but not too tight grip also in technical sections. 


Pressure on the palms of your hands may also cause numbness and/or pain.


The reason therefore is described in detail in Rich Manson's answer. Unergonomic hand and arm position on flat handlebars exacerbates this. Some grips, mitts, bars or a changed position on the bike might help. The latter is the easiest to fix: check if your position on the bike is good. See Craig Hicks' answer on how to improve your position on your bike.

Lastly, unless you are in a race, simply take a break from time to time. This helps immensely with many other forms of cycling discomfort caused by prolonged restrictions of movement.