In this study, an improved version of artificial electric field (AEF) algorithm, named as opposition-based AEF (ObAEF), has been proposed for the first time ever to tune a fractional order PID (FOPID) controller used in a magnetic ball suspension system. The basic AEF algorithm is a novel physics-inspired, population-based meta-heuristic optimization method that mathematically mimics Coulomb's electrostatic force between charged particles. The proposed ObAEF algorithm is the improved version of the AEF which utilizes the opposition-based learning strategy to enhance the AEF algorithm's exploration capability. To validate the performance, the novel ObAEF algorithm was applied to 6 well-known benchmark optimization problems of Sphere, Rosenbrock, Schwefel, Ackley, Egg Crate and Easom. The results were also compared with other algorithms such as basic AEF, atom search optimization (ASO) and artificial bee colony (ABC). It was also used to tune FOPID controller (ObAEF-FOPID) to improve the transient response of a magnetic levitation (maglev) system by minimizing a new objective function having a simple structure. The latter was proposed to minimize the maximum overshoot, settling and rise times along with steady state error of magnetically suspended ball's position. The convergence profile and statistical analyzes were conducted to illustrate the success of the proposed algorithm. The effectiveness and superiority of the ObAEF-FOPID controller was further investigated through frequency response analysis and again compared with AEF, ABC and ASO based FOPID controllers as in statistical success, convergence profile and transient analyses. The results showed that the proposed ObAEF-FOPID has better control performance than those tuned by AEF, ASO and ABC algorithms. (C) 2020 Karabuk University. Publishing services by Elsevier B.V.