‘Huangguan’ pear has excellent quality, strong adaptability, and good socioeconomic value. Iron is one of the important trace elements in plants, and iron imbalance seriously affects the growth and development of pear trees and reduces their economic benefits. If the iron content in pear fruit can be easily and non-destructively detected using modern technology during the critical period of fruit development, it will undoubtedly help guide actual production. In this study, ‘Huangguan’ pear fruit was used as the research object, and the possibility of using the more convenient near-infrared spectroscopy (900~1700 nm) technology for nondestructive detection of the iron content in the peel and pulp of ‘Huangguan’ pear was explored. First, 12 algorithms were used to preprocess the original spectral data, and based on the original and the preprocessed spectral data, partial least squares regression and gradient boosting regression tree algorithms were used. A full-band prediction model of the iron content in the peel and pulp of ‘Huangguan’ pear was established, and the genetic algorithm was used to extract characteristic wavelengths, establish a characteristic wavelength prediction model, and evaluate the prediction effect of each model according to the coefficient of determination R² and the relative analysis error RPD. After comparison, we found that the prediction model with the best prediction of the iron content in the peel and pulp of ‘Huangguan’ pear reaches class A, and the prediction effect is good and meets expectations. This experiment shows that the use of near-infrared spectroscopy can achieve better prediction of the iron content in the peel and pulp of ‘Huangguan’ pear.