Detectors with the capability to directly measure the photon number of a pulse of light enable linear optics quantum computing, affect the security of quantum communications, and can be used to characterize and herald non-classical states of light. Here, we demonstrate the photon-number-resolving capabilities of a quantum-dot, optically gated, field-effect transistor that uses quantum dots as optically addressable floating gates in a GaAsAl0.2Ga0.8As -doped field-effect transistor. When the active area of the detector is illuminated, photo-generated carriers trapped by quantum dots screen the gate field, causing a persistent change in the channel current that is proportional to the number of confined carriers. Using weak laser pulses, we show that discrete numbers of trapped carriers produce well resolved changes in the channel current. We demonstrate that for a mean photon number of 1.1, decision regions can be defined such that the field-effect transistor determines the number of detected photons with a probability of accuracy greater than 83. © 2007 Nature Publishing Group.