Complexity of service environment and particularity of the transportation medium make it difficult to develop a nondestructive stress testing on oil and gas pipelines in real time and online. In this case, a stress detection method of oil and gas pipelines is proposed in this work based on the magnetic mechanical properties of pipeline steel materials and the magnetic induction intensity stress coupling relationship. Six commonly used pipeline steels (X52, X56, X60, X65, X70, and X80) are selected as the research objects to test the hysteresis curves. The key parameters of local magnetization of oil and gas pipelines are determined based on their magnetic properties. A finite element simulation model is established for oil and gas pipelines with magnetic field and stress field coupling. The magnetic field distribution and magnetic induction intensity along the length of the pipeline and the height of cross section are studied after local magnetization of the simulation model of oil and gas pipelines unpressurized. The mechanism of magnetic induction intensity and stress variation of the simulation model of oil and gas pipelines with different internal pressures are discussed. The coupling relationship of axial stress, circumferential stress, and magnetic induction intensity are separately established. The systems for stress-strain test and magnetic induction intensity test are integrated to test the X80 pipeline steel. Analysis results on test data and finite element simulation data verify the validity of magnetic coupling simulation of oil and gas pipelines and the reliability of stress detection, which provides a theoretical basis for the key technologies of nondestructive online stress detection of oil and gas pipelines.