We revisit a little known theorem due to Beltrami, through which the integration of the geodesic equations of a curved manifold is accomplished by a method which, even if inspired by the Hamilton-Jacobi method, is purely geometric. The application of this theorem to the Schwarzschild and Kerr metrics leads straightforwardly to the general solution of their geodesic equations. This way of dealing with the problem is, in our opinion, very much in keeping with the geometric spirit of general relativity. In fact, thanks to this theorem we can integrate the geodesic equations by a geometrical method and then verify that the classical conservation laws follow from these equations.