Oxidative stress injury and cell death in alveolar epithelial cells may lead to abnormal repair, further resulting in acute and chronic pulmonary diseases. Substance P (SP) has multiple biological activities. The Sonic hedgehog (SHH) pathway is important in lung development and decreasing epithelial injury. To investigate the effects of SP on alveolar epithelial type II cells (AEC IIs), AEC IIs were exposed to 95% oxygen and the SHH signaling pathway was examined. Primary AEC IIs were isolated and purified from premature rats. The cells were divided into four groups: The air (21% oxygen) group, hyperoxia (95% oxygen) group, hyperoxia + SP group and hyperoxia + SP + L703.606 group. The activity of AEC IIs was examined using a 3‑(4,5‑dimethylthiazol‑2‑yl)‑2,5‑diphenyltetrazolium bromide assay. The apoptotic rate of AEC IIs was analyzed by flow cytometry. The oxidative damage was evaluated by flow cytometry and reactive oxygen species (ROS) were detected using a 2',7'‑dichlorodihydrofluorescein diacetate probe. Quantitative polymerase chain reaction and western blotting were used to detect the mRNA and protein expression of the SHH signaling molecule Smoothened (SMO). The results demonstrated that exposure to 95% oxygen for 24 h significantly increased the level of ROS, contributed to apoptosis and markedly decreased the proliferation of AEC IIs. Compared with hyperoxia exposure, SP treatment decreased the level of ROS, reduced AEC II apoptosis and improved the cell survival sequentially. SMO was found to be expressed in AEC IIs and its expression increased when the cells were in hyperoxic conditions. These effects were enhanced by treatment with SP, which was able to significantly increase the expression of SMO. The aforementioned protective effect was weakened following treatment with L703.606. These findings suggested that SP was a protective regulatory factor that was able to decrease the hyperoxia‑induced cell injury and death, and improve the survival of AEC IIs exposed to hyperoxia, which may be associated with the activation of the SHH signaling pathway.