Obtaining detailed information about the ocean through seafloor optical imaging is crucial, yet poses significant challenges due to the high attenuation of light, which necessitates the camera to be positioned within several meters of the seafloor. This paper proposes a method for an autonomous underwater vehicle (AUV) to track the seafloor at a close range suitable for optical survey. Through the probabilistic processing of measurements from a mechanical scanning imaging sonar, the AUV can safely follow the seafloor, even in the presence of large obstacles or overhanging geometries. The method was implemented on the low‐cost AUV, HATTORI, and its effectiveness was confirmed by sea experiments around Nishinoshima island, an uninhabited volcanic island located about 1000 km south of Tokyo, Japan. Detailed images of the rugged seafloor were successfully captured under the challenging condition of strong currents.