A gaffer is the head of the electrical department. He or she establishes an electrical "hub" from which other departments can draw power, either on set or on location, but his or her main duties have to do with rigging the lighting necessary to film a scene. It is for this reason that American productions, like Torchwood: Miracle Day, use the wordier synonym, chief lighting technician.
In addition to managing the technical setup of the lights, he also manages the quality of the light through the application of gels. Gaffers are ultimately responsible for translating a lighting design into a practical reality.
The person creating that design has changed during the course of the production history of Doctor Who. During the 1963 version, especially in the earliest years, there was no distinction between a gaffer and a lighting director, at least insofar as the credits were concerned. The only lighting credit issued was one for studio lighting. In this case, the gaffer either was the lighting director, or the actual gaffers simply went uncredited. Even as late as the Sylvester McCoy era, no one was receiving a lighting credit for episodes filmed primarily on location, indicating a formal lighting director was not used by the Doctor Who production office.
With the advent of the BBC Wales version, however, Doctor Who has adopted a hierarchy more common to film production. In this scheme, the director of photography is in charge of creating the lighting design and the gaffer organises the team to make it happen. Underneath him is the best boy, his senior assistant; underneath the best boy are a team of largely uncredited riggers.
The modern gaffer is roughly of equivalent rank to the key grip, who also reports directly to the director of photography, and is in charge of the physical movement of the camera.