Abstract We propose a variational method for determining homoclinic and heteroclinic orbits including spiral-shaped ones in nonlinear dynamical systems. Starting from a suitable initial curve, a homotopy evolution equation is used to approach a true connecting orbit. The procedure is an extension of a variational method that has been used previously for locating cycles, and avoids the need for linearization in search of simple connecting orbits. Examples of homoclinic and heteroclinic orbits for typical dynamical systems are presented. In particular, several heteroclinic orbits of the steady-state Kuramoto–Sivashinsky equation are found, which display interesting topological structures, closely related to those of the corresponding periodic orbits.