A fundamental limit to existing optical techniques for measurement and manipulation of spin degrees of freedom is set by diffraction, which does not allow spins separated by less than about a quarter of a micrometre to be resolved using conventional far-field optics. Here, we report an efficient far-field optical technique that overcomes the limiting role of diffraction, allowing individual electronic spins to be detected, imaged and manipulated coherently with nanoscale resolution. The technique involves selective flipping of the orientation of individual spins, associated with nitrogen-vacancy centres in room-temperature diamond, using a focused beam of light with intensity vanishing at a controllable location, which enables simultaneous single-spin imaging and magnetometry at the nanoscale with considerably less power than conventional techniques. Furthermore, by inhibiting spin transitions away from the laser intensity null, selective coherent rotation of individual spins is realized. This technique can be extended to subnanometre dimensions, thus enabling applications in diverse areas ranging from quantum information science to bioimaging.