Precision laser spectroscopy1of cold and trapped molecular ions is a powerful tool in fundamental physics—used, for example, in determining fundamental constants2, testing for their possible variation in the laboratory3,4, and searching for a possible electric dipole moment of the electron5. However, the absence of cycling transitions in molecules poses a challenge for direct laser cooling of the ions6, and for controlling7-11and detecting their quantum states. Previously used state-detection techniques based on photodissociation12or chemical reactions13are destructive and therefore inefficient, restricting the achievable resolution in laser spectroscopy. Here, we experimentally demonstrate non-destructive detection of the quantum state of a single trapped molecular ion through its strong Coulomb coupling to a well controlled, co-trapped atomic ion. An algorithm based on a state-dependent optical dipole force14changes the internal state of the atom according to the internal state of the molecule. We show that individual quantum states in the molecular ion can be distinguished by the strength of their coupling to the optical dipole force. We also observe quantum jumps (induced by black-body radiation) between rotational states of a single molecular ion. Using the detuning dependence of the state-detection signal, we implement a variant of quantum logic spectroscopy15,16of a molecular resonance. Our state-detection technique is relevant to a wide range of molecular ions, and could be applied to state-controlled quantum chemistry17and to spectroscopic investigations of molecules that serve as probes for interstellar clouds18,19.