We present an analytical method for the calculation of cogging torque in surface permanent-magnet (PM) motors. The cogging torque is calculated by integrating the Maxwell stress tensor inside the air gap. The principle of complex relative air-gap permeance derived from conformal transformation of the slot geometry is used to take into account the effect of slotting and to calculate the radial and tangential components of the air-gap flux density required for integration of the tangential component of the Maxwell stress tensor. We implemented the proposed analytical solution on a 7-kW four-pole surface PM motor and compared the results with finite-element solutions. We present an example of finding the optimal magnet angular span to yield minimum cogging torque as an example of the effectiveness of the method.