We present a nonlinear mean-field model of the solar interior dynamics and dynamo, which reproduces the observed cyclic variations of the global magnetic field of the Sun, as well as the differential rotation and meridional circulation. Using this model, we explain, for the first time, the extended 22-year cycle of the solar torsional oscillations, observed as propagation of zonal variations of the angular velocity from high latitudes to the equator during the time equal to the full dynamo cycle. Our results show that the torsional oscillations result from an overlay of dynamo waves propagating in the bulk of the convection zone. The oscillations are driven by a combinations of magnetic field effects acting on turbulent angular momentum transport the dynamo-induced variations of meridional circulation and the large-scale Lorentz force. They are the primary drivers of the torsional oscillations, and provide necessary conditions for the extended solar-cycle phenomenon.