Adaptive optics by direct imaging of the wavefront distortions of a laser-induced guide star has long been used in astronomy, and more recently in microscopy to compensate for aberrations in transparent specimens. Here we extend this approach to tissues that strongly scatter visible light by exploiting the reduced scattering of near-infrared guide stars. The method enables in vivo two-photon morphological and functional imaging down to 700 μm inside the mouse brain.