The construction of a quantum computer remains a fundamental scientific and technological challenge because of the influence of unavoidable noise. Quantum states and operations can be protected from errors through the use of protocols for quantum computing with faulty components. We present a quantum error-correcting code in which one qubit is encoded in entangled states distributed over seven trapped-ion qubits. The code can detect one bit flip error, one phase flip error, or a combined error of both, regardless on which of the qubits they occur. We applied sequences of gate operations on the encoded qubit to explore its computational capabilities. This seven-qubit code represents a fully functional instance of a topologically encoded qubit, or color code, and opens a route toward fault-tolerant quantum computing.