In this paper, the first-principle calculations of the lateral heterojunction model synthesized by hBN-Graphene were carried out, and it was found that the bandgap of graphene varied with the change in the proportion of hBN, and the bandgap was best regulated with a bandgap of 1.177 eV when the proportion of hBN was 66.67 %. At this time, the adsorption structures of HCN, CO, NH3, and Cl2 were established and energy band calculations were performed on the hBN and Graphene portions of the hBN-Graphene lateral heterojunctions, respectively, and it was found that the adsorption of Cl2 resulted in a significant change in the band gap, which showed a very high electrical sensitivity. To further investigate the adsorption mechanism of Cl2 on the surface of hBN-Graphene lateral heterojunction, the energy band structure, PDOS, charge transfer, adsorption energy, and recovery time of each stabilized adsorption site of Cl2 on the surface of hBN-Graphene lateral heterojunction were calculated. The results show that the adsorption of Cl2 on the surface of hBN-Graphene lateral heterojunction is a stable chemisorption, and the band gap of C-Top1 increases to 1.274 eV, and the band gaps of C-Top3, N-Top1, and N-Top2 decrease to 0.684 eV, 0.376 eV, and 0.398 eV, respectively, and the changes of band gaps are significant and easy to be electrically detection. The recovery time of Cl2 on the surface of hBN-Graphene lateral heterojunction was 7.36 s–2.59 s in visible light and in the temperature interval of 273 K–283 K. The recovery time of Cl2 on the surface of hBN-Graphene lateral heterojunction was 7.36 s–2.59 s in visible light and in the temperature interval of 273 K–283 K. These findings have implications for the research and application of graphene-based Cl2 gas sensors.