A single-electron transistor embedded in a nanomechanical resonator represents an extreme limit of electron-phonon coupling. While it allows fast and sensitive electromechanical measurements, it also introduces backaction forces from electron tunnelling that randomly perturb the mechanical state. Despite the stochastic nature of this backaction, it has been predicted to create self-sustaining coherent mechanical oscillations under strong coupling conditions. Here, we verify this prediction using real-time measurements of a vibrating carbon nanotube transistor. This electromechanical oscillator has some similarities with a laser. The single-electron transistor pumped by an electrical bias acts as a gain medium and the resonator acts as a phonon cavity. Although the operating principle is unconventional because it does not involve stimulated emission, we confirm that the output is coherent. We demonstrate other analogues of laser behaviour, including injection locking, classical squeezing through anharmonicity, and frequency narrowing through feedback.