We describe a variational method to solve the Holstein model for an electron coupled to dynamical, quantum phonons on an infinite lattice. The variational space can be systematically expanded to achieve high accuracy with modest computational resources (12-digit accuracy for the one-dimensional polaron energy at intermediate coupling). We compute ground-state and low-lying excited-state properties of the model at continuous values of the wave vector k in essentially all parameter regimes. Our results for the polaron energy band, effective mass, and correlation functions compare favorably with those of other numerical techniques, including the density-matrix renormalization-group technique, the global-local method, and the exact diagonalization technique. We find a phase transition for the first excited state between a bound and unbound system of a polaron and an additional phonon excitation. The phase transition is also treated in strong-coupling perturbation theory.