The interaction of matter and light is one of the fundamental processes occurring in nature, and its most elementary form is realized when a single atom interacts with a single photon. Reaching this regime has been a major focus of research in atomic physics and quantum optics for several decades and has generated the field of cavity quantum electrodynamics. Here we perform an experiment in which a superconducting two-level system, playing the role of an artificial atom, is coupled to an on-chip cavity consisting of a superconducting transmission line resonator. We show that the strong coupling regime can be attained in a solid-state system, and we experimentally observe the coherent interaction of a superconducting two-level system with a single microwave photon. The concept of circuit quantum electrodynamics opens many new possibilities for studying the strong interaction of light and matter. This system can also be exploited for quantum information processing and quantum communication and may lead to new approaches for single photon generation and detection.