The control of a rotary inverted pendulum (RIP) is challenging because it is an underactuated, highly sensitive, and unsteady system. Sliding mode control (SMC) is a nonlinear control method with high-frequency switching control. Designing a proportional integral derivative (PID) controller for a RIP is challenging due to its nonlinearity and instability in open-loop characteristics. The primacy of the SMC over the PID is the stability of the closed-loop. Hybrid control of a PID-SMC controller can provide better performance because this technique demonstrates less chatter, higher precision, no oscillation, and adequate gain tuning. To achieve gain tuning, the PID and SMC parameters must be optimized. Thus, this paper proposed a congruently tuned control strategy (CTCS) to fine-tune the controller parameters. The proposed strategy uses an improved whale optimization algorithm (WOA), i.e., the modified Manhattan distance updated WOA (MMD-WOA) to identify effective coefficient values for the sliding surface to reduce tracking errors while reaching the desired position. The proposed CTCS for a RIP with the MMD-WOA was implemented, and the results are very promising.