Fungi play a crucial role in ecosystems as decomposers, breaking down organic matter and recycling nutrients back into the soil. They also form symbiotic relationships with plants, such as mycorrhizae, which help plants absorb water and nutrients from the soil. Additionally, fungi can act as parasites, pathogens, or mutualists with other organisms in the ecosystem. Overall, fungi contribute to the balance and functioning of ecosystems by regulating nutrient cycles and supporting plant growth.