Fungi |--Chytridiomycota `--+--o--Zygomycetes | `--Trichomycetes `--+--Basidiomycota | |--Ustilaginomycetes | `--Hymenomycetes `--Ascomycota |--Saccharomycotina `--Pezizomycotina
Although often inconspicuous, fungi occur in every environment on Earth and play very important roles in most ecosystems. Along with bacteria, fungi are the major decomposers in most terrestrial (and some aquatic) ecosystems, and therefore play a critical role in biogeochemical cycles and in many food webs.
Many fungi are important as partners in symbiotic relationships with other organisms, as mutualists, parasites, or commensalists, as well as in symbiotic relationships that do not fall neatly into any of these categories. One of the most critically important of these relationships are various types of mycorrhiza, which is a kind of mutualistic relationship between fungi and plants, in which the plant's roots are closely associated with fungal hyphae and other structures. The plant donates to the fungus sugars and other carbohydrates that it manufactures from photosynthesis, while the fungus donates water and mineral nutrients that the hyphal network is able to find much more efficiently than the plant roots alone can, particularly phosphorus. The fungi also protect against diseases and pathogens and provide other benefits to the plant. Recently, plants have been found to use mycorrhizas to deliver carbohydrates and other nutrients to other plants in the same community and in some cases can make plant species that would normally exclude each other able to coexist in the same plant community. Such mycorrhizal communities are called "common mycorrhizal networks". Over 90% of the plant species on Earth are dependent on mycorrhizae of one type or another in order to survive, and it is hypothesized that the presence of terrestrial fungi may have been necessary in order for the first plants to colonize land.
Lichens are formed by a symbiotic relationship between algae or cyanobacteria (referred to in lichens as "photobionts") and fungi (mostly ascomycetes of various kinds and a few basidiomycetes), in which individual photobiont cells are embedded in a complex of fungal tissue. As in mycorrhizas, the photobiont provides sugars and other carbohydrates while the fungus provides minerals and water. The functions of both symbiotic organisms are so closely intertwined that they function almost as a single organism.
Certain insects also engage in mutualistic relationships with various types of fungi. Several groups of ants cultivate various fungi in the Agaricales as their primary food source, while ambrosia beetles cultivate various kinds of fungi in the bark of trees that they infest. 
Some fungi are parasites on plants, animals (including humans), and even other fungi. Pathogenic fungi are responsible for numerous diseases, such as athlete’s foot and ringworm in humans and Dutch elm disease in plants. Some fungi are predators of nematodes, which they capture using an array of devices such as constricting rings or adhesive nets .