This study formulates three-dimensional (3D) residual flow, treating both stationary and transient waves. The zonal and meridional momentum equations contain four terms: the geostrophic wind tendency, Coriolis force for the residual horizontal flow, product of the geostrophic wind and potential vorticity other than the constant planetary vorticity, and friction. The thermodynamic equation contains three terms: the potential temperature tendency, advection of the basic potential temperature by the residual vertical flow, and diabatic heating. The zonal mean of the 3D residual flow equals the time mean of the residual flow of the transformed Eulerian-mean equations. The new residual flow is the sum of that derived by Plumb for transient waves and the quadratic terms of the time-mean fields, which correspond approximately to the Stokes correction due to stationary waves. The 3D residual flow and momentum equations are symmetric in the zonal and meridional directions, in contrast with those formulated by Kinoshita et al., which treat the time-mean zonal-mean zonal wind as the basic wind. The newly derived formulas are applied to the climatology of the 3D structure of the deep branch of the Brewer–Dobson circulation. In the Northern Hemisphere in December–February, the residual flows are directed inward toward the polar vortex strongly over east Siberia, where the downward flow is maximized, and weakly over the Atlantic; meanwhile, they are directed outward from the vortex over North America and Europe. A longitudinal dependence of the poleward flow is also observed in the Southern Hemisphere in June–August.