We elucidate the origin of the phonon-mediated superconductivity in 2H-NbS2 using the ab initio anisotropic Migdal-Eliashberg theory including Coulomb interactions. We demonstrate that superconductivity is associated with Fermi surface hot spots exhibiting an unusually strong electronphonon interaction. The electron-lattice coupling is dominated by low-energy anharmonic phonons, which place the system on the verge of a charge density wave instability. We also provide denitive evidence for two-gap superconductivity in 2H-NbS2, and show that the low-and high-energy peaks observed in tunneling spectra correspond to the Γ-and K-centered Fermi surface pockets, respectively. The present ndings call for further eorts to determine whether our proposed mechanism underpins superconductivity in the whole family of metallic transition metal dichalcogenides. PACS numbers: 74.70.Xa, 63.20.kd, 74.20.Fg, 74.25.Jb Transition metal dichalcogenides (TMDs) have generated considerable interest in recent years, since they provide an ideal playground for studying semiconductors, metals, and superconductors in two dimensions using the same structural template [13]. In the case of superconducting TMDs, one remarkable feature is that Cooper pair condensation usually coexists with a charge density wave (CDW) [4], raising the question on whether superconductivity and CDW co-operate or compete in these compounds [512].Within the family of superconducting TMDs, 2H-NbS 2 stands out as the only system for which a CDW phase has not been observed [13, 14]. This suggests that a comparative analysis of NbS 2 and other superconducting TMDs may help to clarify the interplay between the superconductive and the CDW instabilities in the entire family. 2H-NbS 2 is a phonon-mediated superconductor with a critical temperature T c = 5.7 K. Scanning tunneling spectroscopy (STS) measurements on this compound revealed two pronounced features in the density of states (DOS) at 0.53 meV and 0.97 meV below the critical temperature, providing strong indications of two-gap superconductivity [14]. However, so far microscopic calculations have considered only a single-gap scenario [15, 16].In this work we investigate the nature of the superconducting gap and the pairing mechanism in 2H-NbS 2 using the fully anisotropic ab initio Migdal-Eliashberg theory, and describe both electron-phonon and electronelectron interactions without any adjustable parameters. Our key nding is that a very signicant contribution to the superconducting pairing comes from the lowenergy anharmonic phonons with wavevectors near the line connecting the M and L points. These are the same phonons responsible for the CDW instability in other TMDs [8, 11, 1719], indicating that superconductivity in NbS 2 is intimately connected with a latent CDW. In agreement with the STS experiments of Ref. 14, we nd two distinct and anisotropic superconducting gaps.All calculations reported in this work were performed using density functional theory (DFT) in the local density approximation [20,21]. We employed...