A 2 DoF MEMS-based nanopositioner with integrated electrothermal sensors for on-chip AFM applications is presented. The electrothermal sensors consist of a pair of 50-μm long silicon heaters that operate in a differential mode. It is demonstrated in this work that the sensor measurements can be used in feedback control loops to improve the quality of AFM images during high-speed raster scanning. The x and y resonance frequencies of the MEMS-based nanopositioner appear at 815 Hz and 800 Hz respectively. To obtain high-speed AFM images, a positive position feedback (PPF) controller is designed to damp the resonant mode of the fast axis and an integrator is used to achieve satisfactory tracking. For the slow axis, a notch filter and an integrator are implemented to track a slow ramp signal. To further increase the tracking bandwidth of the fast axis, an inversion-based feedforward technique is combined with the PPF and integral feedback loops. With the proposed feedforward-feedback control strategy, high-quality AFM images up to 50 Hz line rate are obtained without noticeable vibration-induced artifacts.