Intracranial infection is one of the most serious complications following neurosurgery. It is well acknowledged that bacteria and fungi are the main pathogens responsible for postoperative intracranial infection. However, the microbial community structure, including composition, abundance and diversity, in postoperative intracranial infection is not fully understood, which greatly compromises our understanding of the necessity and effectiveness of postoperative antibiotic treatment. The present study collected eight cerebrospinal fluid (CSF) samples from patients with intracranial infection following neurosurgical procedures. High‑throughput amplicon sequencing for 16S rDNA and internal transcribed spacer (ITS) was performed using the Illumina MiSeq platform to investigate the microbial community composition and diversity between treated and untreated patients. Bioinformatics analysis revealed that the microbial composition and diversity in each patient group (that is, with or without antibiotic treatment) was similar; however, the group receiving antibiotic treatment had a comparatively lower species abundance and diversity compared with untreated patients. At the genus level, Acinetobacter and Staphylococcus were widely distributed in CSF samples from patients with postoperative intracranial infection; in particular, Acinetobacter was detected in all CSF samples. In addition, five ITS fungal libraries were constructed, and Candida was detected in three out of four patients not receiving antibiotic treatment, indicating that the fungal infection should be given more attention. In summary, 16S and ITS high‑throughput amplicon sequencing were practical methods to identify pathogens in the different periods of treatment in patients with postoperative intracranial infection. There was a notable difference in microbial composition and diversity between the treated and untreated patients. Alterations in the microbial community structure may provide a signal whether antibiotic treatment worked in postoperative intracranial infection and may assist surgeons to better control the progression of infection.