Optical frequency combs act as rulers in the frequency domain and have opened new avenues in many fields such as fundamental time metrology, spectroscopy and frequency synthesis. In particular, spectroscopy by means of optical frequency combs has surpassed the precision and speed of Fourier spectrometers. Such a spectroscopy technique is especially relevant for the mid-infrared range, where the fundamental rotational-vibrational bands of most light molecules are found. Most mid-infrared comb sources are based on down-conversion of near-infrared, mode-locked, ultrafast lasers using nonlinear crystals. Their use in frequency comb spectroscopy applications has resulted in an unequalled combination of spectral coverage, resolution and sensitivity. Another means of comb generation is pumping an ultrahigh-quality factor microresonator with a continuous-wave laser. However, these combs depend on a chain of optical components, which limits their use. Therefore, to widen the spectroscopic applications of such mid-infrared combs, a more direct and compact generation scheme, using electrical injection, is preferable. Here we present a compact, broadband, semiconductor frequency comb generator that operates in the mid-infrared. We demonstrate that the modes of a continuous-wave, free-running, broadband quantum cascade laser are phase-locked. Combining mode proliferation based on four-wave mixing with gain provided by the quantum cascade laser leads to a phase relation similar to that of a frequency-modulated laser. The comb centre carrier wavelength is 7 micrometres. We identify a narrow drive current range with intermode beat linewidths narrower than 10 hertz. We find comb bandwidths of 4.4 per cent with an intermode stability of less than or equal to 200 hertz. The intermode beat can be varied over a frequency range of 65 kilohertz by radio-frequency injection. The large gain bandwidth and independent control over the carrier frequency offset and the mode spacing open the way to broadband, compact, all-solid-state mid-infrared spectrometers.