The main goal here is to design a proper and efficient controller for a ship autopilot based on the sliding mode control method. A hydrodynamic numerical model of CyberShip II including wave effects is applied to simulate the ship autopilot system by using time domain analysis. To compare the results similar research was conducted with the PD controller, which was adapted to the autopilot system. The differences in simulation results between two controllers are analyzed by a cost function composed of a heading angle error and rudder deflection either in calm water or in waves. Simulation results show the effectiveness of the method in the presence of nonlinearities and disturbances, and high performance of the proposed controller.