Objective To analyze the effect of the hierarchical medical system on technical efficiency of primary healthcare institutions based on data envelopment analysis (DEA) and difference⁃in⁃differences (DID) models. Methods The DEA model was used to evaluate the technical efficiency (including pure technical efficiency and scale efficiency) of primary healthcare institutions in 31 provinces (autonomous regions and municipalities directly under the central government) across China from 2010 to 2022. The DID model was used to evaluate the pure policy effect of the hierarchical medical system on the technical efficiency of primary healthcare institutions, and robustness tests were conducted. Results The technical efficiency of primary healthcare institutions in China was relatively low (mean value of 0.773), with significant inter⁃regional and intra⁃regional differences. Pure technical efficiency and scale efficiency were generally at a relatively high level (mean values of 0.895 and 0.894, respectively), but the characteristics of inter⁃regional imbalance were prominent. The regression coefficients of the hierarchical medical system and total population were 0.022 and 0.036 (reaching the 10% and 5% significance levels for empirical economic studies, respectively), and the results were robust. Conclusion The hierarchical medical system can significantly improve the technical efficiency of primary healthcare institutions in China, but there are obvious inter⁃regional differences in technical efficiency. Taking targeted measures according to regional characteristics can help give full play to the role of the hierarchical medical system in improving the technical efficiency of primary healthcare institutions.