We report a systematic and comprehensive computational study of the electronic structure of GaN and InN surfaces in various orientations, including the polar c plane, as well as the nonpolar a and m planes. Surface band structures and density-of-states plots show the energetic position of surface states, and by correlating the electronic structure with atomistic information we are able to identify the microscopic origins of each of these states. Fermi-level pinning positions are identified, depending on surface stoichiometry and surface polarity. For polar InN we find that all the surface states are located above the conduction-band minimum, and explain the source of the intrinsic electron accumulation that has been universally observed on InN surfaces.