Many ecologists study communities in the context of an ecosystem, which includes interactions involving mineral cycling, energy flow, and population control. The study of ecosystems facilitates a functional approach to ecology.

One of the major aims of ecological research is to determine how organisms retain and recycle the minerals within an ecosystem. All minerals used by organisms are important, but some, such as those rich in nitrogen and phosphorous, are used in larger amounts or may be less available than others. Herbivores speed the recycling of minerals by eating plant parts and then excreting some of these materials; minerals in the plants are thus returned to the soil faster than if the plants had not been eaten. Scavengers help by breaking down large dead organisms faster than bacteria or fungi alone, and bacteria and fungi eventually break down fecal material and other smaller organic matter into its mineral components. Carnivores feeding on herbivores also help to recycle the minerals found in the bodies of herbivores. Roots of plants may absorb these materials for reuse or may absorb minerals from soil made available by weathering processes. Some minerals, however, will escape from the ecosystem and end up eventually in the oceans.

A second functional aspect of ecosystems is energy flow. In the 1920s, Charles Elton pointed out that there was a pyramid of trophic (food) levels: the base of the pyramid was composed of producers; above them were a smaller number of herbivores and a still smaller number of carnivores. Ecosystem ecologists prefer to express these relationships by the amount of energy passing through each of the trophic levels in a given period of time. Because of the properties of energy, as expressed in the laws of conservation and of entropy, there is always more energy passing through the producers in a given unit of time than there is in the herbivores that eat them, and still less in their predators, and so on.

All energy in ecosystems comes from the Sun. A small part of this energy (1% to 2%) is captured by plants and stored as energy-rich chemical bonds in the compounds of their protoplasm. Only 1% to 20% of this energy is passed on to herbivores, and a similar energy loss occurs at each higher trophic level. This phenomenon has three important effects: it limits the possible number of trophic levels (there are usually no more than five); it affects the size of the organisms in each succeeding trophic level, so that carnivores are usually larger than other species; and it absolutely limits the amount of energy available to organisms in each level.

Energy is lost at each trophic level for several reasons: heat is created as chemical bonds are changed into mechanical energy or other forms; energy is used for metabolic processes (especially respiration); the organisms at one trophic level are not completely utilized by those at the next higher level; and food passing through animals' digestive tracts is not completely digested. For example, only about 10% of the leaves of trees, and even less of the roots and stems, are eaten by insects. Much of the energy that does not pass through herbivores or carnivores eventually passes through scavengers and decomposers. Some of this energy may then flow into predators that feed on these forms and may thereby be passed back into the main energy pyramid. Aphids excrete much of the sugary sap that they suck from veins in leaves, which then appears as honeydew beneath the trees. When glucose is respired in cells, no more than 50% of its energy is converted into other chemical bonds; the rest is given off as heat.

The amount of energy stored during a given unit of time by green plants as a result of photosynthesis is called primary productivity. The amount of energy stored by animals in a given unit of time is called secondary productivity. The percentage of energy that passes from one trophic level to the next is called ecological efficiency.

A third major ecological function is population regulation. One of the functions of herbivores is to control plant populations. The moth Cactoblastis cactorum, for example, was introduced into Australia to control a runaway population of prickly pear cactus (Opuntia) that had been introduced earlier. Predators and parasites may also serve as controls over organisms they eat. Insects that prey on other invertebrates may indeed control their prey, which often cannot escape or hide. Such is the case with the ladybird beetle, which can control such pests as the mealybug. With larger animals, such as foxes and rabbits, the situation is much more complex; the control of rabbits, for instance, may involve density-independent factors such as severe winters and drought, as well as density-dependent controls such as predators and parasites. (The control effectiveness of density-independent factors does not change as the population size changes, whereas that of density-dependent factors does.)