Previous studies on microbes associated with deterioration of cultural heritage (CH) stoneworks have revealed a diverse microbiota adapted to stresses such as low nutrients, aridity and high salinity, temperatures and radiation. However, the function of these pioneer microbial communities is still unclear. This study examines bacterial and archaeal diversity in exfoliated and dark encrustation sandstone from Portchester Castle (UK) by 16S rRNA and functional gene analyses. Bacterial and archaeal communities from the exfoliated sites were distinctly different from the dark encrustation. Detected genera were linked to extreme environmental conditions, various potential functional roles and degradation abilities. From these data it was possible to reconstruct almost complete nitrogen and sulfur cycles, as well as autotrophic carbon fixation and mineral transformation processes. Analysis of RNA showed that many of the detected genera in these nutrient cycles were probably active in situ. Thus, CH stonework microbial communities are highly diverse and potentially self‐sustaining ecosystems capable of cycling carbon, nitrogen and sulphur as well as the stone biodeterioration processes that lead to alterations such as exfoliation and corrosion. These results highlight the importance of diversity and internal recycling capacity in the development of microbial communities in harsh and low energy systems.