The concepts of both Fermi surface nesting and local chemical bonding were employed to analyze the electronic origin of the structural modulations of layered transition-metal dichalcogenides 1T-MX2 and 2H-MX2. Analogies between the two concepts and their complementary nature were examined. The concept of hidden Fermi surface nesting was used to explain the d-electron-count dependence of the structural modulations of the 1T-MX2 layers containing d4/3, d2, and d3 ions on the basis of their hidden one-dimensional Fermi surfaces. The latter are derived from the observations that these layers are made up of three different sets of edge-sharing octahedral chains and that strong sigma-bonding interactions between the t2g orbitals occur along each chain direction. From the viewpoint of local chemical bonding, the driving force for the diamond-chain formation in the d3 systems and the zigzag-chain formation in the d2 systems is two-center, two-electron sigma-bonding, but that for the ribbon-chain formation in the d4/3 SyStems is three-center, two-electron sigma-bonding. Several structural modulations of 1T-MX2 and 2H-MX2 layers, difficult to understand in terms of Fermi surface nesting, were examined by performing molecular orbital and tight-binding band electronic structure calculations. The square-root 13 X square-root 13 modulation of a d1 1T-MX2 layer is described as a superposition of linear, multicenter sigma-bonding interactions which occur in three different directions around metal atoms. The 2 x 2 modulation of 1T-TiSe2 results from a second-order Jahn-Teller instability of the TiSe6 octahedra with d0 ions. The 3 x 3 modulation of a d1 2H-MX2 layer occurs to enhance the extent of the metal-metal bonding interactions between adjacent MX6 trigonal prisms. Structural modulations arising from Fermi surface nesting in low-dimensional metals are equivalent in nature to first-order Jahn-Teller distortions of molecules. Structural modulations of low-dimensional metals do not always originate from Fermi surface nesting, just as not all molecular distortions are caused by first-order Jahn-Teller distortions.