In the deep-sea environment, the volume available for an in-situ gene sequencer is severely limited. In addition, optical imaging systems are subject to real-time, large-scale defocusing problems caused by ambient temperature fluctuations and vibrational perturbations. To address these challenges, we propose an edge detection algorithm for defocused images based on grayscale gradients and establish a defocus state detection model with nanometer resolution capabilities by relying on the inherent critical illumination light field. The model has been applied to a prototype deep-sea gene sequencing microscope with a 20× objective. It has demonstrated the ability to focus within a dynamic range of ±40 μm with an accuracy of 200 nm by a single iteration within 160 ms. By increasing the number of iterations and exposures, the focusing accuracy can be refined to 78 nm within a dynamic range of ±100 μm within 1.2 s. Notably, unlike conventional photoelectric hill-climbing, this method requires no additional hardware and meets the wide dynamic range, speed, and high-accuracy autofocusing requirements of deep-sea gene sequencing in a compact form factor.