The president won a solid victory, prevailing in most of the hotly contested swing states, including Pennsylvania and Ohio, whose economies have benefited from new discoveries of oil and natural gas, as well as Colorado and Iowa, where support for renewable energy became a key campaign issue.