Community detection is one of the fundamental problems of network analysis,\nfor which a number of methods have been proposed. Most model-based or\ncriteria-based methods have to solve an optimization problem over a discrete\nset of labels to find communities, which is computationally infeasible. Some\nfast spectral algorithms have been proposed for specific methods or models, but\nonly on a case-by-case basis. Here we propose a general approach for maximizing\na function of a network adjacency matrix over discrete labels by projecting the\nset of labels onto a subspace approximating the leading eigenvectors of the\nexpected adjacency matrix. This projection onto a low-dimensional space makes\nthe feasible set of labels much smaller and the optimization problem much\neasier. We prove a general result about this method and show how to apply it to\nseveral previously proposed community detection criteria, establishing its\nconsistency for label estimation in each case and demonstrating the fundamental\nconnection between spectral properties of the network and various model-based\napproaches to community detection. Simulations and applications to real-world\ndata are included to demonstrate our method performs well for multiple problems\nover a wide range of parameters.\n