  The realization of quantum error correction is an essential ingredient for
reaching the full potential of fault-tolerant universal quantum computation.
Using a range of different schemes, logical qubits can be redundantly encoded
in a set of physical qubits. One such scalable approach is based on the surface
code. Here we experimentally implement its smallest viable instance, capable of
repeatedly detecting any single error using seven superconducting qubits, four
data qubits and three ancilla qubits. Using high-fidelity ancilla-based
stabilizer measurements we initialize the cardinal states of the encoded
logical qubit with an average logical fidelity of 96.1%. We then repeatedly
check for errors using the stabilizer readout and observe that the logical
quantum state is preserved with a lifetime and coherence time longer than those
of any of the constituent qubits when no errors are detected. Our demonstration
of error detection with its resulting enhancement of the conditioned logical
qubit coherence times in a 7-qubit surface code is an important step indicating
a promising route towards the realization of quantum error correction in the
surface code.
