This article aims to solve multiple problems associated with attitude estimation; the complexity of Kalman filter (KF) calculations in the attitude and heading reference system (AHRS), the interference sensitivity of magnetic, angular rate, and gravity (MARG) sensors, and the low accuracy of the factored quaternion algorithm (FQA). It presents a two-layer linear KF using MARG sensors to obtain attitude estimation in quaternions. First, data from a triaxial accelerometer and magnetometer is processed by a novel algorithm, which fuses the quaternion estimator (QUEST) algorithm and FQA by the linear interpolation (LERP) to obtain an observation model. Second, the process model in the two-layer KF was obtained by using LERP to fuse an optimum quaternion obtained from a gyroscope and FQA. The LERP can eliminate gyro bias drift, and integral error, and compensate for unexpected conditions, such as fast rotation and temporary strong magnetic disturbances. The proposed algorithm presents higher accuracy and lower computational load than QUEST or FQA used with a KF alone. The performance of the proposed algorithm is verified through simulation and experiments.