Abstract. A generally relativistic theory of thermodynamics is developed, based on four main physical principles: heat is a local form of energy, therefore described by a thermal energy tensor; conservation of mass, equivalent to conservation of heat, or the local first law; entropy is a local current; and non-destruction of entropy, or the local second law. A fluid is defined by the thermostatic energy tensor being isotropic. The entropy current is related to the other fields by certain equations, including a generalised Gibbs equation for the thermostatic entropy, followed by linear and quadratic terms in the dissipative (thermal minus thermostatic) energy tensor. Then the second law suggests certain equations for the dissipative energy tensor, generalising the Israel-Stewart dissipative relations, which describe heat conduction and viscosity including relativistic effects and relaxation effects. In the thermostatic case, the perfect-fluid model is recovered. In the linear approximation for entropy, the Eckart theory is recovered. In the quadratic approximation for entropy, the theory is similar to that of Israel & Stewart, but involving neither state-space differentials, nor a non-equilibrium Gibbs equation, nor non-material frames. Also, unlike conventional thermodynamics, the thermal energy density is not assumed to be purely thermostatic, though this is derived in the linear approximation. Otherwise, the theory reduces in the non-relativistic limit to the extended thermodynamics of irreversible processes due to Müller. The dissipative energy density seems to be a new thermodynamical field, but also exists in relativistic kinetic theory of gases.