The aim of this study was to examine the effect of calcitonin gene-related peptide (CGRP) on primary alveolar epithelial type II (AECII) cells and expression of Sonic hedgehog (SHH) signaling pathway components following exposure to hyperoxia. The AECII cells were isolated and purified from premature rats and exposed to air (21% oxygen), air + CGRP, hyperoxia (95% oxygen) or hyperoxia + CGRP. The production of intracellular reactive oxygen species (ROS) was determined using the 2',7'-dichlorofluorescin diacetate molecular probe. The levels of malondialdehyde (MDA) and superoxide dismutase (SOD) in the culture supernatant were detected by spectrophotometry. The apoptosis of AECII cells was assayed by flow cytometry, and the mRNA and protein expression levels of Shh and Ptc1 in the AECII cells were detected by reverse transcription-quantitative polymerase chain reaction (RT-qPCR), western blot analysis and immunofluorescence, respectively. The cellular pathological changes partly improved and apoptosis was markedly decreased upon treatment with CGRP under hyperoxic conditions. The levels of ROS in the hyperoxia + CGRP group were significantly lower than thoe in the hyperoxia group. In addition, the hyperoxia-induced increase in MDA levels and the decrease in SOD activity in the culture supernatant of the AECII cells were attenuated by CGRP. Compared with the cells exposed to air, hyperoxia markedly inhibited the mRNA and protein expression levels of Shh and Ptc1 in the AECII cells; however, this inhibition was partly attenuated by treatment with CGRP. On the whole, our data suggest that CGRP can partly protect AECII cells from hyperoxia-induced injury, and the upregulation of CGRP may be a potential therapeutic approach with which to combat hyperoxia-induced lung injury, which may be associated with the activation of the SHH signaling pathway.