This study focuses on the design of a robust PD gain-scheduling controller (PD-GS-C) for an unstable SISO (single-input, single-output) magnetic levitation system with two electromagnets (MLS2EM). Magnetic levitation systems offer various advantages, including friction-free, reliable, fast, and cost-effective operations. However, due to their unstable and highly nonlinear nature, these systems require sophisticated feedback control techniques to ensure optimal performance and functionality. To address these challenges, in this study, we derive the nonlinear state-space mathematical model of the MLS2EM and linearize it around five different operating points. The PD-GS-C controller aims to stabilize the system and improve steady-state control error. The strategy for obtaining the PD controller gains involves a parameter space technique, which specifies performance requirements. This technique results in ranges of proportional (KP) and derivative (KD) gains that are used by the PD-GS-C structure. To optimize the controller’s performance further, we utilize the big bang–big crunch optimization technique (BB-BC) to determine the optimal PD gains within the specified ranges. The optimization process focuses on achieving optimal performance in terms of a specific performance index function. This function quantifies the system’s time-domain step response criteria, which include minimizing overshoot percentage, settling time, and rising time. The index function is inversely proportional to the desired performance criteria, meaning that the goal is to maximize the index function to optimize the system’s performance. To validate the effectiveness and viability of the proposed strategy, we conducts MATLAB simulations and real-time experiments. The simulations and experimental findings serve to demonstrate the controller’s performance and verify its capabilities in stabilizing the MLS2EM magnetic levitation system.