MAGINAV (MAGnetic Inertial NAVigation) algorithm provides accurate estimation of velocity, attitude and position in long-term. It is utilized in a specialized pedestrian navigation system that consists of a 3-axis accelerometer, a 3-axis gyroscope, and a 3-axis magnetometer mounted on the shoe of a walking human. MAGINAV compensates for the attitude error, accumulated over time by utilizing a second attitude estimation obtained by fusing the measurements from the accelerometer and the magnetometer Instead of employing a complex Attitude Heading Reference System (AHRS), MAGINAV utilizes the computationally efficient TRIAD algorithm, alongside two popular algorithms for zero-velocity detection and magneticdisturbance detection respectively.The proposed algorithm undergoes testing in an outdoor environment utilizing low-cost commercial inertial and magnetic field sensors. Remarkably, it achieves exceptional long-term accuracy, with a position error that is less than 0.25% of the total distance in a 20-minute walk spanning 1.3km.