That ended Tuesday in an election in which more than 119 million votes were cast, mostly without controversy despite dire predictions of politically charged recounts and lawsuits while the presidency hung in the balance.
Obama won the popular vote narrowly, the electoral vote comfortably, and the battleground states where the campaign was principally waged in a landslide.
The president carried seven of the nine states where he, Romney and their allies spent nearly $1 billion on television commercials, winning Ohio, Wisconsin, Iowa, New Hampshire, Nevada, Colorado and Virginia.
The Republican challenger won North Carolina, and Florida remained too close to call
Obama also turned back late moves by Republicans in Pennsylvania, Michigan and Minnesota.
Hispanics account for a larger share of the population than the national average in Nevada and Colorado, two of the closely contested battleground states. The president's outsized majority among Hispanics — in the range of 70 percent according to Election Day interviews with voters — helped him against a challenger who called earlier in the year for self-deportation of illegal immigrants.
Other factors in crucial states:
— In Ohio, roughly 60 percent of all voters said they favored the Obama administration's auto bailout, and the president captured nearly three quarters of their votes, according to the survey, conducted for The Associated Press and a group of television networks. He stressed the rescue operation throughout the campaign. Romney opposed it, and in late campaign commercials suggested it had contributed to the loss of U.S. jobs overseas.
— In Virginia, the black vote was roughly half again as big in percentage terms as nationally, also an aid to Obama.
Changes are in store for the victorious administration. The election past, three members of Obama's Cabinet have announced plans to leave their posts: Defense Secretary Leon Panetta, Treasury Secretary Tim Geithner and Secretary of State Hillary Rodham Clinton. Other changes would not be unusual in the second administration of any president.
As for Congress, Democrats improbably gained seats in re-establishing their Senate majority. Their final margin hinged on a decision by independent Sen.-elect Angus King of Maine, who has not yet said which party he will affiliate with.
There were nine House races that remained too close to call, not counting a Louisiana runoff next month that involves two Republicans. Overall, the GOP secured 234 seats and led for one more, a trend that would translate into a net loss of eight from the current lineup.
In defeat, Democrats pointed to races where they turned tea party-backed conservatives out of power as evidence they had stemmed a tide.
Associated Press writers Julie Pace in Chicago and Donna Cassata, Larry Margasak and Andrew Taylor in Washington contributed to this story.