The effect of an initially grown high-temperature AlN buffer (HT-AlN) layer's thickness on the quality of an AlN epilayer grown on sapphire substrate by metalorganic chemical vapor deposition (MOCVD) in a two-step growth process is investigated. The characteristics of AlN epilayers are analyzed by using triple-axis crystal X-ray diffraction (XRD) and atomic force microscopy (AFM). It is shown that the crystal quality of the AlN epilayer is closely related to its correlation length. The correlation length is determined by the thickness of the initially grown HT-AlN buffer layer. We find that the optimal HT-AlN buffer thickness for obtaining a high-quality AlN epilayer grown on sapphire substrate is about 20 nm.