The YORP effect is produced when the surface of a small object in interplanetary space is heated by sunlight and reradiates the absorbed energy in thermal wavelengths. The absorbed, reflected, and emitted photons produce tiny torques on the small body that can change its spin rate and obliquity over planetary timescales. Previous theories of the YORP effect relied on numerical or seminumerical evaluation of the radiation torques. Here we develop an alternative approach and calculate the YORP torques analytically. Our theory is limited to near-spherical objects. While unsuitable for a precise determination of torques on elongated and /or highly irregular objects, the analytic theory helps to explain several general properties of the YORP torques that were identified in previous numerical works. For example, we demonstrate that the component of the YORP torque that affects the spin rate,¯s, can vanish for obliquity values % 55 (and % 125 ). As discussed by Vokrouhlický and coworkers, this property of¯s is important for establishing the so-called Slivan states, which arise as evolutionary end states of spin vectors of small solar system bodies such as asteroids. We show that¯s (averaged over spin and orbit periods) is a second-order quantity in the small parameter that describes the deviation of the shape from an ideal sphere. We calculate¯s explicitly as polynomials of cos . These expressions show that the YORP torque arises from coupled deformations of the body's shape in topographic longitude and latitude. Moreover, by introducing a small phase lag to mimic the delay between the absorption and reemission of photons we demonstrate that¯s is insensitive to the exact value of the surface thermal conductivity. These and other analytic results described here provide a baseline for understanding the YORP effect on bodies with more complicated surface shapes and properties other than the ones considered here. We discuss applications of the analytic theory on near-spherical asteroids like 1998 KY 26 and on more elongated and/or irregular objects like (1862) Apollo and (25143) Itokawa.