In the hard x-ray region, to obtain the theoretical resolution or diffraction-limited focusing size in an imaging optical system, both ultraprecise optics and highly accurate alignment are necessary. An adaptive optical system is used for the compensation of aberrations in various optical systems, such as optical microscopes and space telescopes. In situ wavefront control of hard x-rays is also effective for realizing ideal performance. The aim of this paper is to develop an adaptive optical system for sub-10-nm hard x-ray focusing. The adaptive optical system performs the wavefront measurement using a phase retrieval algorithm and wavefront control using grazing-incidence deformable mirrors. Several results of experiments using the developed system are reported.