The faithful storage of a quantum bit (qubit) of light is essential for long-distance quantum communication, quantum networking and distributed quantum computing. The required optical quantum memory must be able to receive and recreate the photonic qubit; additionally, it must store an unknown quantum state of light better than any classical device. So far, these two requirements have been met only by ensembles of material particles that store the information in collective excitations. Recent developments, however, have paved the way for an approach in which the information exchange occurs between single quanta of light and matter. This single-particle approach allows the material qubit to be addressed, which has fundamental advantages for realistic implementations. First, it enables a heralding mechanism that signals the successful storage of a photon by means of state detection; this can be used to combat inevitable losses and finite efficiencies. Second, it allows for individual qubit manipulations, opening up avenues for in situ processing of the stored quantum information. Here we demonstrate the most fundamental implementation of such a quantum memory, by mapping arbitrary polarization states of light into and out of a single atom trapped inside an optical cavity. The memory performance is tested with weak coherent pulses and analysed using full quantum process tomography. The average fidelity is measured to be 93%, and low decoherence rates result in qubit coherence times exceeding 180 microseconds. This makes our system a versatile quantum node with excellent prospects for applications in optical quantum gates and quantum repeaters.