Selective harmonic elimination (SHE) technique is used in power inverters to eliminate specific lower-order harmonics by determining optimum switching angles that are used to generate Pulse Width Modulation (PWM) signals for multilevel inverter (MLI) switches. Various optimization algorithms have been developed to determine the optimum switching angles. However, these techniques are still trapped in local optima. This study proposes an opposition-based quantum bat algorithm (OQBA) to determine these optimum switching angles. This algorithm is formulated by utilizing habitual characteristics of bats. It has advanced learning ability that can effectively remove lower-order harmonics from the output voltage of MLI. It can eventually increase the quality of the output voltage along with the efficiency of the MLI. The performance of the algorithm is evaluated with three different case studies involving 7, 11, and 17-level three-phase MLIs. The results are verified using both simulation and experimental studies. The results showed substantial improvement and superiority compared to other available algorithms both in terms of the harmonics reduction of harmonics and finding the correct solutions.