Detection of the extremely weak signals in spectroscopy over an extremely wide frequency region is central to diverse sciences, including materials science, biology, astronomy and chemistry. Here we show a new type of atomic-scale spectroscopy, heterodyne scanning tunnelling spectroscopy (HSTS), which is based on the innovative application of the nonlinear heterodyne-mixing detection at the metal-insulator-metal (MIM) heterojunction of STM tip-vacuum-sample. The principle of HSTS is identical to that of the Atacama Large Millimeter Array (ALMA) space telescope in terms of using heterojunction for detecting extremely weak signals by converting from terahertz region to lower frequency regions. The MIM detector of ALMA, which is composed of niobium-titanium-nitride (NbTiN) tip-insulator-NbTiN, is very similar in shape and size to that of HSTS. We successfully detect a heterodyne beat signal f₃(= |f₂- f₁) and intermodulation distortion via tunnelling current by superimposing two different AC signals, f₁ and f₂, onto the DC tunnelling current at a highly oriented pyrolytic graphite (HOPG) surface. We then obtain spectra of the localized electronic states of HOPG by using f₃. HSTS can be performed with a high resolution and over a wide energy range, including the terahertz range.