In the present work, a novel method is devised for controlling an uncertain wheeled mobile robot (WMR) in a desired path. To achieve this objective, an optimal and robust control system with adaptive gains is combined to benefit from the advantages of both methods. In fact, applying this controller not only controls a nonlinear system robustly against uncertainties and external disturbances, but also optimizes a quadratic cost function. Also, since the upper bound of uncertainty is determined by an adaptive law, it does not need to be adjusted manually. To ensure the designed controller's finite time stability, Lyapunov theory is used. Finally, to illustrate the effectiveness of the proposed control method, a case study involving a WMR is presented. By comparing the results of this approach with those of an adaptive sliding mode control (ASMC), it is shown that the proposed controller uses less control effort, relative to the ASMC controller, to stabilize the uncertain WMR in the presence of external disturbances.