A set of equations in the Lagrangian description are derived for the propagation of long gravity waves in two horizontal directions for the purpose of determining the response of harbours with sloping boundaries to long waves. The equations include terms to account for weakly nonlinear and dispersive processes. A finite element formulation for these equations is developed which treats the propagation of transient waves in regions of arbitrary shape with vertical or sloping boundaries. Open boundaries are treated by specifying the wave elevation along the boundary or by applying a radiation boundary condition to absorb the waves leaving the computational domain. Nonlinear aspects of the interaction of long gravity waves with sloping boundaries and frequency dispersion due to non-hydrostatic effects are investigated. Results from the model are then compared with laboratory experiments of the response to long-wave excitation of a narrow rectangular harbour with a depth that decreases linearly from the entrance to the shore line.