Fungi play a crucial role in ecosystems as they are decomposers, breaking down organic matter like dead plants and animals, and recycling nutrients back into the environment. They also form symbiotic relationships with plants, helping them absorb water and nutrients from the soil. Additionally, some fungi are predators, feeding on other organisms in the ecosystem. Overall, fungi contribute to the balance and functioning of ecosystems by playing various ecological roles.