In this paper, an optimal fuzzy sliding mode controller has been designed for controlling the end-effector position in the task space. In the proposed control, feedback linearization method, sliding mode control, first-order fuzzy TSK system and optimization algorithm are utilized. In the proposed controller, a novel heuristic algorithm namely self-adaptive modified bat algorithm (SAMBA) is employed. To achieve an optimal performance, the parameters of the proposed controller as well as the input membership functions are optimized by SAMBA simultaneously. In this method, the bounds of structural and non-structural uncertainties are reduced by using feedback linearization method, and to overcome the remaining uncertainties, sliding mode control is employed. Mathematical proof demonstrates that the closed loop system with the proposed control has global asymptotic stability. The presence of sliding mode control gives rise to the adverse phenomenon of chattering in the end-effector position tracking in the task space. Subsequently, to prevent the occurrence of chattering in control input, a first-order TSK fuzzy approximator is utilized. Finally, to determine the fuzzy sliding mode controller coefficients, the optimization algorithm of Self-Adaptive Modified Bat is employed. To investigate the performance of the proposed control, a two-degree-of-freedom manipulator is used as a case study. The simulation results indicate the favorable performance of the proposed method.