1 Ectomycorrhizal fungi are spatially associated with established ectomycorrhizal vegetation, but the influence of distance from established vegetation on the presence, abundance, diversity and community composition of fungi is not well understood. 2 We examined mycorrhizal communities in two abandoned agricultural fields in Minnesota, USA, using Quercus macrocarpa seedlings as an in situ bioassay for ectomycorrhizal fungi from 0 to 20 m distance from the forest edge. 3 There were marked effects of distance on all aspects of fungal communities. The abundance of mycorrhiza was uniformly high near trees, declined rapidly around 15 m from the base of trees and was uniformly low at 20 m. All seedlings between 0 and 8 m distance from forest edges were ectomycorrhizal, but many seedlings at 16–20 m were uninfected in one of the two years of the study. Species richness of fungi also declined with distance from trees. 4 Different species of fungi were found at different distances from the edge. ‘Rare’ species (found only once or twice) dominated the community at 0 m, Russula spp. were dominants from 4 to 12 m, and Astraeus sp. and a Pezizalean fungus were abundant at 12 m to 20 m. Cenococcum geophilum , the most dominant species found, was abundant both near trees and distant from trees, with lowest relative abundance at intermediate distances. 5 Our data suggest that seedlings germinating at some distance from established ectomycorrhizal vegetation (15.5 m in the present study) have low levels of infection, at least in the first year of growth. Distance from established vegetation represents an important gradient for ectomycorrhizal fungi, with different species occupying distinct niches along this gradient. This provides support for niche differentiation as a factor contributing to ectomycorrhizal fungal diversity. 6 Ectomycorrhizal infection of seedlings is spatially complex, with high infection and high fungal diversity near trees, high infection but lower diversity at intermediate distances, and low infection and low fungal diversity distant from trees. This spatial complexity should be considered as a factor potentially influencing the establishment of ectomycorrhizal vegetation.