J.W. Gibbs developed the thermodynamic theory of capillarity based
on the idea of surfaces of discontinuity. Gibbs considered the case of a sharp mathematical surface being placed somewhere within the microscopically fuzzy physical interface that exists between two homogeneous substances. Realizing that the exact choice of the surface's location was somewhat arbitrary, he left it flexible. Since the interface exists in thermal and chemical equilibrium with the substances around it (having temperature  and chemical potentials ), Gibbs considered the case where the surface may have excess energy, excess entropy, and excess particles, finding the natural free energy function in this case to be , a quantity later named as the grand potential and given the symbol .
Considering a given subvolume  containing a surface of discontinuity, the volume is divided by the mathematical surface into two parts A and B, with volumes  and , with  exactly. Now, if the two parts A and B were homogeneous fluids (with pressures , ) and remained perfectly homogeneous right up to the mathematical boundary, without any surface effects, the total grand potential of this volume would be simply . The surface effects of interest are a modification to this, and they can be all collected into a surface free energy term  so the total grand potential of the volume becomes:
For sufficiently macroscopic and gently curved surfaces, the surface free energy must simply be proportional to the surface area:
for surface tension  and surface area .
As stated above, this implies the mechanical work needed to increase a surface area A is , assuming the volumes on each side do not change. Thermodynamics requires that for systems held at constant chemical potential and temperature, all spontaneous changes of state are accompanied by a decrease in this free energy , that is, an increase in total entropy taking into account the possible movement of energy and particles from the surface into the surrounding fluids. From this it is easy to understand why decreasing the surface area of a mass of liquid is always spontaneous, provided it is not coupled to any other energy changes. It follows that in order to increase surface area, a certain amount of energy must be added.
Gibbs and other scientists have wrestled with the arbitrariness in the exact microscopic placement of the surface. For microscopic surfaces with very tight curvatures, it is not correct to assume the surface tension is independent of size, and topics like the Tolman length come into play. For a macroscopic-sized surface (and planar surfaces), the surface placement does not have a significant effect on ; however, it does have a very strong effect on the values of the surface entropy, surface excess mass densities, and surface internal energy, which are the partial derivatives of the surface tension function .
Gibbs emphasized that for solids, the surface free energy may be completely different from surface stress (what he called surface tension): the surface free energy is the work required to form the surface, while surface stress is the work required to stretch the surface. In the case of a two-fluid interface, there is no distinction between forming and stretching because the fluids and the surface completely replenish their nature when the surface is stretched. For a solid, stretching the surface, even elastically, results in a fundamentally changed surface. Further, the surface stress on a solid is a directional quantity (a stress tensor) while surface energy is scalar.
Fifteen years after Gibbs, J.D. van der Waals developed the theory of capillarity effects based on the hypothesis of a continuous variation of density. He added to the energy density the term  where c is the capillarity coefficient and ρ is the density. For the multiphase equilibria, the results of the van der Waals approach practically coincide with the Gibbs formulae, but for modelling of the dynamics of phase transitions the van der Waals approach is much more convenient. The van der Waals capillarity energy is now widely used in the phase field models of multiphase flows. Such terms are also discovered in the dynamics of non-equilibrium gases.