Spectroscopy is a well-established nonintrusive tool that has played an important role in identifying and quantifying substances, from quantum descriptions to chemical and biomedical diagnostics. Challenges exist in accurate spectrum analysis in free space, which hinders us from understanding the composition of multiple gases and the chemical processes in the atmosphere. A photon-counting distributed free-space spectroscopy is proposed and demonstrated using lidar technique, incorporating a comb-referenced frequency-scanning laser and a superconducting nanowire single-photon detector. It is suitable for remote spectrum analysis with a range resolution over a wide band. As an example, a continuous field experiment is carried out over 72 h to obtain the spectra of carbon dioxide (CO2) and semi-heavy water (HDO, isotopic water vapor) in 6 km, with a range resolution of 60 m and a time resolution of 10 min. Compared to the methods that obtain only column-integrated spectra over kilometer-scale, the range resolution is improved by 2–3 orders of magnitude in this work. The CO2 and HDO concentrations are retrieved from the spectra acquired with uncertainties as low as ±1.2%and ±14.3%, respectively. This method holds much promise for increasing knowledge of atmospheric environment and chemistry researches, especially in terms of the evolution of complex molecular spectra in open areas.