Present-day implementations of quantum information processing rely on two widely different types of quantum bits (qubits). On the one hand, microscopic systems such as atoms or spins are naturally well decoupled from their environment and as such can reach extremely long coherence times [1,2]; on the other hand, more macroscopic objects such as superconducting circuits are strongly coupled to electromagnetic fields, making them easy to entangle [3,4] although with shorter coherence times [5,6]. It thus seems appealing to combine the two types of systems in hybrid structures that could possibly take the best of both worlds. Here we report the first experimental realization of a hybrid quantum circuit in which a superconducting qubit of the transmon type [5,7] is coherently coupled to a spin ensemble consisting of nitrogen-vacancy (NV) centers in a diamond crystal [8] via a frequency-tunable superconducting resonator [9] acting as a quantum bus. Using this circuit, we prepare arbitrary superpositions of the qubit states that we store into collective excitations of the spin ensemble and retrieve back later on into the qubit. We demonstrate that this process preserves quantum coherence by performing quantum state tomography of the qubit. These results constitute a first proof of concept of spin-ensemble based quantum memory for superconducting qubits [10][11][12]. As a landmark of the successful marriage between a superconducting qubit and electronic spins, we detect with the qubit the hyperfine structure of the NV center.Superconducting qubits have been successfully coupled to electromagnetic [13] as well as mechanical [14] resonators; but coupling them to microscopic systems in a controlled way has up to now remained an elusive perspective -even though qubits sometimes turn out to be coupled to unknown and uncontrolled microscopic degrees of freedom with relatively short coherence times [15]. Whereas the coupling constant g of one individual microscopic system to a superconducting circuit is usually too weak for quantum information applications, ensembles of N such systems are coupled with a constant g √ N enhanced by collective effects.This makes possible to reach a regime of strong coupling between one collective variable of the ensemble and the circuit. This collective variable, which behaves in the low excitation limit as a harmonic oscillator, has been proposed [10-12] as a quantum memory for storing the state of superconducting qubits. Experimentally, the strong coupling between an ensemble of electronic spins and a superconducting resonator has been demonstrated 2 spectroscopically [16][17][18], and the storage of a microwave field into collective excitations of a spin ensemble has been observed very recently [19,20]. These experiments were however carried out in a classical regime since the resonator and spin ensemble behaved as two coupled harmonic oscillators driven by large microwave fields. In the perspective of building a quantum memory, it is instead necessary to perform experiments at the level of a...