The pigmentation of hairs is achieved by the follicular melanocytes (specialized pigment cells) at the base of the hair shaft. These cells produce the pigment which is subsequently transported into the cells which produce the hair and integrated into the hair matrix.
Besides genetic reasons, there are two major ways of loosing this pigmentation. First, as a part of the normal hair cycle, the hair grows for a while until it falls out and the hair follicle regresses. In this process the cells in the hair follicle die, including which made the hair as well as of the melanocytes. In this step of the hair cycle the hair follicle changes its morphology. When a new haircycle starts, the pigment cells in the hair follicle are replenished from a stem cell population called melanocyte stem cells. These cells are located in the hair bulge (marked in red in the figure below). The cells then start to proliferate to multiply their number. Few of these cells stay stem cells (to be able to repopulate the pigment cells after the next hair cycle) other differentiate into melanocytes which subsequently migrate towards the bottom of the hair bulb (shown in green in the figure).
Over time, the number of stem cells gets lower and at some point, there are none left. This leads to a situation where the pigment cells are not replenished at the beginning of a new hair cycle and the hair stays unpigmented. As this is a continous process, the pigmentation gets weaker before it is completely lost. As far as this process is understood to date, this depigmentation is irreversible.
There are two very interesting papers about this topic:
The other reason for loosing pigmentation (temporarily or permanent) is the generation of so called "reactive oxygen species" (Hydrogenperoxide) in the cells of the hair follice, which then destroy the pigment. This is basically the same reaction which is used to bleach hairs, but in this instance from inside. This reaction can have numerous reasons, among them are vitiligo and stress. The reason for the build-up of the hydrogenperoxides is that enzymes, which usually break them down before they can cause harm are either mutated or downregulated. If the level of these enzymes (the catalases) goes back to normal, pigmentation is also getting back to normal. This has been tested experimentally with people which suffer from the pigmentation disease vitiligo.