Devices that harness the laws of quantum physics hold the promise for information processing that outperforms their classical counterparts, and for unconditionally secure communication1. However, in particular, implementations based on condensed-matter systems face the challenge of short coherence times. Carbon materials2,3, particularly diamond 4-6, however, are suitable for hosting robust solid-state quantum registers, owing to their spin-free lattice and weak spin-orbit coupling. Here we show that quantum logic elements can be realized by exploring long-range magnetic dipolar coupling between individually addressable single electron spins associated with separate colour centres in diamond. The strong distance dependence of this coupling was used to characterize the separation of single qubits (98±3Ȧ ) with an accuracy close to the value of the crystal-lattice spacing. Our demonstration of coherent control over both electron spins, conditional dynamics, selective readout as well as switchable interaction should open the way towards a viable room-temperature solid-state quantum register. As both electron spins are optically addressable, this solid-state quantum device operating at ambient conditions provides a degree of control that is at present available only for a few systems at low temperature.