This paper presents an algorithm to estimate the relative orientation of body segments during 3D motion tracking, either as multiple individual body segments or as an articulated body chain. For this purpose, a double-stage data fusion algorithm (algorithm-based system) was implemented for inertial measurement units (IMU)/Magnetic Angular Rate and Gravity (MARG)-based wearable sensors during gait. The methodology considers two stages of complementary filters for the data fusion of the IMU/MARG sensors and a Proportional-Integral controller (PI) to incorporate the processed data. Quaternions were employed for the orientation estimation, a Direction Cosine Matrix quaternion-based (DCM) to estimate the relative orientation between the body mobile coordinate system and the inertial reference coordinate system, and Euler angles for the orientation representation. A customized Ambulatory Sensing Motion System (ASMS), consisting of seven monitoring devices was used for the evaluation. The double-stage algorithm-based system was compared with a digital motion processor (DMP) performance. Experimental results of the double-stage algorithm-based system indicated a 0.7° RMSE (M1) and 1° RMSE (M1-M7) with mean values lower than 1° concerning the DMP outcomes. Based on the Bland-Altman analysis, the level of agreement indicated that the double-stage algorithm-based system is neither underestimated nor overestimated and is suitable for the DMP outcome. No singularity conditions nor significant levels of noise or drift were observed in the conducted experiments. The results demonstrate the feasibility of using the proposed method for 3D human motion tracking of multiple body segments, individually or as an articulated body chain. Besides, it suits different IMU/MARG sensor-based wearable sensors.