In analogy to transistors in classical electronic circuits, a quantum optical switch is an important element of quantum circuits and quantum networks [1][2][3]. Operated at the fundamental limit where a single quantum of light or matter controls another field or material system [4], it may enable fascinating applications such as long-distance quantum communication [5], distributed quantum information processing[2] and metrology [6], and the exploration of novel quantum states of matter [7]. Here, by strongly coupling a photon to a single atom trapped in the near field of a nanoscale photonic crystal cavity, we realize a system where a single atom switches the phase of a photon, and a single photon modifies the atom's phase. We experimentally demonstrate an atom-induced optical phase shift [8] that is nonlinear at the two-photon level [9], a photon number router that separates individual photons and photon pairs into different output modes [10], and a single-photon switch where a single "gate" photon controls the propagation of a subsequent probe field [11, 12]. These techniques pave the way towards integrated quantum nanophotonic networks involving multiple atomic nodes connected by guided light.A quantum optical switch [11,[13][14][15][16]] is challenging to implement because the interaction between individual photons and atoms is generally very weak. Cavity quantum electrodynamics (cavity QED), where a photon is confined to a small spatial region and made to interact strongly with an atom, is a promising approach to overcome this challenge [4]. Over the last two decades, cavity QED has enabled advances in the control of microwave [17][18][19] and optical fields [13,[20][21][22][23]. While integrated circuits with strong coupling of microwave photons to superconducting qubits are currently being developed [24], a scalable path to integrated quantum circuits involving coherent qubits coupled via optical photons has yet to emerge.Our experimental approach, illustrated in Figure 1a, makes use of a single atom trapped in the near field of a nanoscale photonic crystal (PC) cavity that is attached * These authors contributed equally to this work † vuletic@mit.edu ‡ lukin@fas.harvard.eduto an optical fiber taper [2]. The tight confinement of the optical mode to a volume V ∼ 0.4 λ 3 , below the scale of the optical wavelength λ, results in strong atom-photon interactions for an atom sufficiently close to the surface of the cavity. The atom is trapped at about 200 nm from the surface in an optical lattice formed by the interference of an optical tweezer and its reflection from the side of the cavity (see Methods Summary, SI and Fig. 1a,b). Compared to transient coupling of unconfined atoms [13, 22], trapping an atom allows for experiments exploiting long atomic coherence times, and enables scaling to quantum circuits with multiple atoms. We use a one-sided optical cavity with a single port for both input and output [8]. In the absence of intracavity loss, photons incident on the cavity are always reflected. However, a s...