This research investigates control theory using an advanced two-dimensional inverted magnetic needle system. The complex dynamics of the system are caused by a non-uniform external magnetic field. The system dynamics are established using Euler's equations, and an energy-based controller is proposed to stabilize the needle near an unstable equilibrium point. We propose energy-based control techniques and compare their performance to the Model Predictive Controller (MPC) performance. An important contribution of this research is the rigorous investigation of closed-loop system stability using Lyapunov function analysis and the tracking performance of energy-based control techniques and MPC controller. The dynamic behavior of the magnetic needle is further enriched by two rotational degrees of freedom, influenced by attractive and repulsive forces from external magnets. Moreover, we assess the effectiveness of energy-based control strategies in both uniform and non-uniform magnetic fields, thereby expanding the applications of control theory.