Trees are an important part of the terrestrial ecosystem, providing essential habitats including many kinds of forest for communities of organisms. Epiphytic plants such as ferns, some mosses, liverworts, orchids and some species of parasitic plants (e.g., mistletoe) hang from branches; these along with arboreal lichens, algae, and fungi provide micro-habitats for themselves and for other organisms, including animals. Leaves, flowers and fruits are seasonally available. On the ground underneath trees there is shade, and often there is undergrowth, leaf litter, and decaying wood that provide other habitat. Trees stabilise the soil, prevent rapid run-off of rain water, help prevent desertification, have a role in climate control and help in the maintenance of biodiversity and ecosystem balance.
Many species of tree support their own specialised invertebrates. In their natural habitats, 284 different species of insect have been found on the English oak (Quercus robur) and 306 species of invertebrate on the Tasmanian oak (Eucalyptus obliqua). Non-native tree species provide a less biodiverse community, for example in the United Kingdom the sycamore (Acer pseudoplatanus), which originates from southern Europe, has few associated invertebrate species, though its bark supports a wide range of lichens, bryophytes and other epiphytes.
In ecosystems such as mangrove swamps, trees play a role in developing the habitat, since the roots of the mangrove trees reduce the speed of flow of tidal currents and trap water-borne sediment, reducing the water depth and creating suitable conditions for further mangrove colonisation. Thus mangrove swamps tend to extend seawards in suitable locations. Mangrove swamps also provide an effective buffer against the more damaging effects of cyclones and tsunamis.