During the Steam-Assisted Gravity Drainage (SAGD) technology-based dual horizontal well drilling process, it is necessary to accurately monitor the well spacing in real time to ensure safe and parallel drilling. In this paper, a self-excited codirectionally magnetically compensated rotating ranging method and device is proposed. In the numerical calculation and simulation, both parallel and nonparallel drilling models are established. Based on the models and the magnetic dipole theory, the relation between the magnetization field and the well spacing is analyzed. Furthermore, the one-to-one correspondence between the peak-to-peak value of the magnetization field and the well spacing is revealed. Well spacing is then determined according to the measured peak-to-peak value. To achieve better results, the influence of magnetic source (the magnetic moment) and casing characteristics (magnetic susceptibility, dynamic magnetization length) on measured peak-to-peak value is analyzed. Finally, field tests are carried out, and the feasibility and effectiveness of the theory and device are proved. This study provides innovation for a new approach of magnetic guidance while drilling and has a great significance in the development, testing, and calibration of well-ranging instruments.