Electromagnetic signals are always composed of photons, although in the circuit domain those signals are carried as voltages and currents on wires, and the discreteness of the photon's energy is usually not evident. However, by coupling a superconducting quantum bit (qubit) to signals on a microwave transmission line, it is possible to construct an integrated circuit in which the presence or absence of even a single photon can have a dramatic effect. Such a system1can be described by circuit quantum electrodynamics (QED)-the circuit equivalent of cavity QED, where photons interact with atoms or quantum dots. Previously, circuit QED devices were shown to reach the resonant strong coupling regime, where a single qubit could absorb and re-emit a single photon many times2. Here we report a circuit QED experiment in the strong dispersive limit, a new regime where a single photon has a large effect on the qubit without ever being absorbed. The hallmark of this strong dispersive regime is that the qubit transition energy can be resolved into a separate spectral line for each photon number state of the microwave field. The strength of each line is a measure of the probability of finding the corresponding photon number in the cavity. This effect is used to distinguish between coherent and thermal fields, and could be used to create a photon statistics analyser. As no photons are absorbed by this process, it should be possible to generate non-classical states of light by measurement and perform qubit-photon conditional logic, the basis of a logic bus for a quantum computer.