Trophic structure, or the distribution of biomass among producers and consumers, determines key ecosystem values, such as the abundance of infectious, harvestable or conservation target species, and the storage and cycling of carbon and nutrients. There has been much debate on what controls ecosystem trophic structure, yet the answer is still elusive. Here we show that the nutritional quality of primary producers controls the trophic structure of ecosystems. By increasing the efficiency of trophic transfer, higher producer nutritional quality results in steeper ecosystem trophic structure, and those changes are more pronounced in terrestrial than in aquatic ecosystems probably due to the more stringent nutritional limitation of terrestrial herbivores. These results explain why ecosystems composed of highly nutritional primary producers feature high consumer productivity, fast energy recycling, and reduced carbon accumulation. Anthropogenic changes in producer nutritional quality, via changes in trophic structure, may alter the values and functions of ecosystems, and those alterations may be more important in terrestrial ecosystems.