Dead wood quantity and quality is important for forest biodiversity, by determining wood-inhabiting fungal assemblages. We therefore evaluated how fungal communities were regulated by stem traits and compartments (i.e. bark, outer- and inner wood) of 14 common temperate tree species. Fresh logs were incubated in a common garden experiment in a forest site in the Netherlands. After 1 and 4 years of decay, the fungal composition of different compartments was assessed using Internal Transcribed Spacer amplicon sequencing. We found that fungal alpha diversity differed significantly across tree species and stem compartments, with bark showing significantly higher fungal diversity than wood. Gymnosperms and Angiosperms hold different fungal communities, and distinct fungi were found between inner wood and other compartments. Stem traits showed significant afterlife effects on fungal communities; traits associated with accessibility (e.g. conduit diameter), stem chemistry (e.g. C, N, lignin) and physical defence (e.g. density) were important factors shaping fungal community structure in decaying stems. Overall, stem traits vary substantially across stem compartments and tree species, thus regulating fungal communities and the long-term carbon dynamics of dead trees.