Approximately half of the extrasolar planets (exoplanets) with radii less than four Earth radii are in orbits with short periods. Despite their sheer abundance, the compositions of such planets are largely unknown. The available evidence suggests that they range in composition from small, high-density rocky planets to low-density planets consisting of rocky cores surrounded by thick hydrogen and helium gas envelopes. Here we report the metallicities (that is, the abundances of elements heavier than hydrogen and helium) of more than 400 stars hosting 600 exoplanet candidates, and find that the exoplanets can be categorized into three populations defined by statistically distinct (~4.5σ) metallicity regions. We interpret these regions as reflecting the formation regimes of terrestrial-like planets (radii less than 1.7 Earth radii), gas dwarf planets with rocky cores and hydrogen-helium envelopes (radii between 1.7 and 3.9 Earth radii) and ice or gas giant planets (radii greater than 3.9 Earth radii). These transitions correspond well with those inferred from dynamical mass estimates, implying that host star metallicity, which is a proxy for the initial solids inventory of the protoplanetary disk, is a key ingredient regulating the structure of planetary systems.