Real-time imaging of moving organs and tissues at microscopic resolutions represents a major challenge in studying the complex biology of live animals. Here we present a technique based on a novel stabilizer setup combined with a gating acquisition algorithm for the imaging of a beating murine heart at the single-cell level. The method allows serial in vivo fluorescence imaging of the beating heart in live mice in both confocal and nonlinear modes over the course of several hours. We demonstrate the utility of this technique for in vivo optical sectioning and dual-channel time-lapse fluorescence imaging of cardiac ischaemia. The generic method could be adapted to other moving organs and thus broadly facilitate in vivo microscopic investigations.