Sensing and compensating of optical aberrations in closed-loop mode using a single spatial light modulator (SLM) for ophthalmic applications is demonstrated. Notwithstanding the disadvantages of the SLM, in certain cases, this multitasking capability of the device makes it advantageous over existing deformable mirrors (DMs), which are expensive and in general used for aberration compensation alone. A closed-loop adaptive optics (AO) system based on a single SLM was built. Beam resizing optics were used to utilize the large active area of the device and hence make it feasible to generate 137 active subapertures for wavefront sensing. While correcting Zernike aberrations up to fourth order introduced with the help of a DM (for testing purposes), diffraction-limited resolution was achieved. It is shown that matched filter and intensity-weighted centroiding techniques stand out among others. Closed-loop wavefront correction of aberrations in backscattered light from the eyes of three healthy human subjects was demonstrated after satisfactory results were obtained using an artificial eye, which was simulated with a short focal length lens and a sheet of white paper as diffuser. It is shown that the closed-loop AO system based on a single SLM is capable of diffraction-limited correction for ophthalmic applications.