This is known as the extension gene. This gene controls the "extension" of black pigment across the body. The dominant form is E, in which black pigment extends across the entire body (resulting in a black horse), the recessive form is e, in which no black pigment is expressed on the body leaving only the red pigment visible (resulting in a chestnut horse).
As there are always a pair of genes for every trait, a horse may be either EE (black), Ee (black) or ee (chestnut).