This study was conducted to characterize the diversity and function of microbial communities in marine sediments of the Pearl River Mouth Basin (PRMB) in the South China Sea. The results showed that the bacterial and archaeal communities varied greatly with depth. Proteobacteria in bacterial communities and Nitrososphaeria and Woesearchaeota in archaeal communities were dominant in the shallow sediments (1–40 cm), while Chloroflexi in bacterial communities and Bathyarchaeia in archaeal communities were dominant in the deep sediments (50–200 cm). Regarding ecological functions based on the metatranscriptomic data, genes involved in various pathways of nitrogen metabolism and sulfur metabolism were observed in the tested sediment samples. Metagenomic analysis revealed that Proteobacteria contribute the most to nearly all genes involved in nitrogen and sulfur metabolism. Moreover, Thaumarchaeota contribute the most to certain genes involved in nitrification, denitrification and assimilatory sulfate reduction pathways. The most abundant bacterial genus, Candidatus Scalindua, is crucial for nitrification, dissimilatory nitrate reduction, denitrification and assimilatory sulfate reduction pathways.