Discretization of the pressure-gradient force is a long-standing problem in terrain-following (or σ) coordinate oceanic modeling. When the isosurfaces of the vertical coordinate are not aligned with either geopotential surfaces or isopycnals, the horizontal pressure gradient consists of two large terms that tend to cancel; the associated pressure-gradient error stems from interference of the discretization errors of these terms. The situation is further complicated by the nonorthogonality of the coordinate system and by the common practice of using highly nonuniform stretching for the vertical grids, which, unless special precautions are taken, causes both a loss of discretization accuracy overall and an increase in interference of the component errors. In the present study, we design a pressure-gradient algorithm that achieves more accurate hydrostatic balance between the two components and does not lose as much accuracy with nonuniform vertical grids at relatively coarse resolution. This algorithm is based on the reconstruction of the density field and the physical z coordinate as continuous functions of transformed coordinates with subsequent analytical integration to compute the pressure-gradient force. This approach allows not only a formally higher order of accuracy, but it also retains and expands several important symmetries of the original second-order scheme to high orders [Mellor et al., 1994; Song, 1998], which is used as a prototype. It also has built-in monotonicity constraining algorithm that prevents appearance of spurious oscillations of polynomial interpolant and, consequently, insures numerical stability and robustness of the model under the conditions of nonsmooth density field and coarse grid resolution. We further incorporate an alternative method of dealing with compressibility of seawater, which escapes pressure-gradient errors associated with interference of the nonlinear nature of equation of state and difficulties to achieve accurate polynomial fits of resultant in situ density profiles. In doing so, we generalized the monotonicity constraint to guarantee nonnegative physical stratification of the reconstructed density profile in the case of compressible equation of state. To verify the new method, we perform traditional idealized (Seamount) and realistic test problems.