Equilibrium thermodynamic laws are typically applied to horizons in general relativity without stating the conditions that bring them into equilibrium. We fill this gap by applying a new thermodynamic interpretation to a generalized Raychaudhuri equation for a worldsheet orthogonal to a closed spacelike 2-surface, the "screen", which encompasses a system of arbitrary size in nonequilibrium with its surroundings in general. In the case of spherical symmetry this enables us to identify quasilocal thermodynamic potentials directly related to standard quasilocal energy definitions. Quasilocal thermodynamic equilibrium is defined by minimizing the mean extrinsic curvature of the screen. Moreover, without any direct reference to surface gravity, we find that the system comes into quasilocal thermodynamic equilibrium when the screen is located at a generalized apparent horizon. Examples of the Schwarzschild, Friedmann-Lemaitre and Lemaitre-Tolman geometries are investigated and compared. Conditions for the quasilocal thermodynamic and hydrodynamic equilibrium states to coincide are also discussed, and a quasilocal virial relation is suggested as a potential application of this approach.