We consider the problem of enumerating spanning trees on lattices. Closed-form expressions are obtained for the spanning tree generating function for a hypercubic lattice in d dimensions under free, periodic, and a combination of free and periodic boundary conditions. Results are also obtained for a simple quartic net embedded on two nonorientable surfaces, a Möbius strip and the Klein bottle. Our results are based on the use of a formula expressing the spanning tree generating function in terms of the eigenvalues of an associated tree matrix. An elementary derivation of this formula is given.