A method which models two- or three-dimensional cavitating hydrofoils moving with constant speed under a free surface is described, An integral equation is obtained by applying Green's theorem on all surfaces of the fluid domain. This integral equation is divided into two parts: (i) the cavitating hydrofoil problem, and (ii) the free-surface problem. These hive problems are solved separately, with the effects of one on the other being accounted for in an iterative manner. The cavitating hydrofoil surface and the free surface are modeled with constant strength dipole and source panels. The source strengths on the free surface are expressed in terms of the second derivative of the potential with respect to the horizontal axis by applying the linearized free-surface conditions. The induced potential by the cavitating hydrofoil on the free surface and by the free surface on the hydrofoil are determined in an iterative sense. In order to prevent upstream waves the source strengths from some distance in front of the hydrofoil to the end of the truncated upstream boundary are enforced to be equal to zero. No radiation condition is enforced at the downstream boundary or at the transverse boundary The method is applied to 2-D and 3-D hydrofoil geometries in fully wetted or cavitating flow conditions and the predictions are compared with those of other methods in the literature.