|The Sun has a near-surface shear layer (NSSL), within which the angular velocity decreases rapidly with radius. We provide a theoretical explanation of this layer based on the thermal wind balance equation. Since convection is not affected by solar rotation in the top layer of the convection zone, we argue that the temperature falls at the same rate at all latitudes in this layer. This makes the thermal wind term very large in this layer, and the centrifugal term has also to become very large to balance it, giving rise to the NSSL. From the values of differential rotation Ω(r < rc, θ) at radii less than a radius rc, we can calculate the temperature difference ΔT(r, θ) with respect to the standard solar model at different points of the convection zone by making use of the thermal wind balance equation. Then, we again use this equation in the top layer to calculate Ω(r > rc, θ) there from ΔT(r, θ). We find that our theoretical results of the NSSL match the observational data reasonably well for rc ≈ 0.96R⊙, giving an estimate of the radius till which the convective motions are affected by the solar rotation.