Integrated nanophotonic devices create strong light-matter interactions that are important for the development of solid-state quantum networks(1), distributed quantum computers(2) and ultralow-power optoelectronics(3,4). A key component for many of these applications is the photonic quantum logic gate, where the quantum state of a solid-state quantum bit (qubit) conditionally controls the state of a photonic qubit. These gates are crucial for the development of robust quantum networks(5-7), non-destructive quantum measurements(8,9) and strong photon-photon interactions(10). Here, we experimentally realize a quantum logic gate between an optical photon and a solid-state qubit. The qubit is composed of a quantum dot strongly coupled to a nanocavity, which acts as a coherently controllable qubit system that conditionally flips the polarization of a photon on picosecond timescales, implementing a controlled-NOT gate. Our results represent an important step towards solid-state quantum networks and provide a versatile approach for probing quantum dot-photon interactions on ultrafast timescales.