Optical laser fields have been widely used to achieve quantum control over the motional and internal degrees of freedom of atoms and ions, molecules and atomic gases. A route to controlling the quantum states of macroscopic mechanical oscillators in a similar fashion is to exploit the parametric coupling between optical and mechanical degrees of freedom through radiation pressure in suitably engineered optical cavities. If the optomechanical coupling is 'quantum coherent'--that is, if the coherent coupling rate exceeds both the optical and the mechanical decoherence rate--quantum states are transferred from the optical field to the mechanical oscillator and vice versa. This transfer allows control of the mechanical oscillator state using the wide range of available quantum optical techniques. So far, however, quantum-coherent coupling of micromechanical oscillators has only been achieved using microwave fields at millikelvin temperatures. Optical experiments have not attained this regime owing to the large mechanical decoherence rates and the difficulty of overcoming optical dissipation. Here we achieve quantum-coherent coupling between optical photons and a micromechanical oscillator. Simultaneously, coupling to the cold photon bath cools the mechanical oscillator to an average occupancy of 1.7 ± 0.1 motional quanta. Excitation with weak classical light pulses reveals the exchange of energy between the optical light field and the micromechanical oscillator in the time domain at the level of less than one quantum on average. This optomechanical system establishes an efficient quantum interface between mechanical oscillators and optical photons, which can provide decoherence-free transport of quantum states through optical fibres. Our results offer a route towards the use of mechanical oscillators as quantum transducers or in microwave-to-optical quantum links.