Anaerobic fermentation of waste biomass via microbial chain elongation for producing medium-chain fatty acids (MCFAs) is becoming an emerging and economically viable technology. However, due to the large abundant of microbial species and great diversity of microbial metabolic pathways in open cultures, how to achieve the high yields of MCFAs is an important topic. In this study, the effect of pH, as an important parameter for process control, on the production and composition of volatile fatty acids (VFAs) in two cycles of anaerobic chain elongation process with cornstalk as feedstock was investigated, and the 16S rRNA high throughput sequencing was employed to elucidate the mechanism of pH affecting chain elongation process. The results showed that pH significantly influenced the VFAs production and their spectra. At pH 5.6, the VFAs production was 10.0 g/L, which was increased to 15.9 g/L at pH 7.0, and was further increased to 18.8 g/L at pH 9.0. In addition, the metabolic pathways and the VFAs composition in anaerobic fermentation were greatly changed with pH regulation. Under acidic and neutral conditions (pHs of 5.6 and 7.0), the chain elongation was enhanced, and butyrate and caproate were the major products accounting for more than 80%. Specially, under the neutral condition, the caproate concentration reached (3.49±0.17) g/L. However, the pH of 9.0 seriously inhibited the chain elongation, and the major fermentation products were acetate (93.2%) and propionate (5.5%). The second-cycle fermentation with supplementing additional ethanol as an electron donor indicated that pH played the more important role in the chain elongation process for a high level MCFAs production. In the second cycle, the chain elongation reaction did not occur under the acidic conditions. However, when the pH was adjusted from 5.6 to 7.0, the chain elongation reaction was significantly stimulated, and the caproate concentration quickly increased from 1.88 to 11.8 g/L. The results of microbial community analysis showed that the fermentative bacteria of Firmicutes were the dominate population under the neutral pH condition accounting for 49.9%, which was far higher than those under the acidic and alkaline conditions. The strains relating to the chain elongation, such as Clostridium IV , Clostridium XI , Clostridium XIVa , Clostridium XIVb , Clostridium XVIII and Clostridium sensu stricto , were enriched under the neutral and acidic conditions, but not under the alkaline condition. It should be noted that the well-known pure culture bacteria relating to chain elongation, such as Clostridium Kluyveri , were not found in this study. In the second cycle, no significant difference on the relative abundance of strains relating to chain elongation was found between neutral and acidic conditions, suggesting that these strains could survive under the acidic conditions but their activity was inhibited. When the pH was adjusted from 5.6 to 7.0, their activities could quickly recover to produce caproate. The above findings provided an effective regulating strategy for selective production of MCFAs from waste biomass with open cultures of microbial consortia.