Barack Hussein Obama was re-elected president of the United States on Tuesday, overcoming powerful economic headwinds, a lock-step resistance to his agenda by Republicans in Congress and an unprecedented torrent of advertising as a divided nation voted to give him more time.

In defeating Mitt Romney, the president carried Colorado, Iowa, Ohio, New Hampshire, Virginia and Wisconsin, a near sweep of the battleground states, and was holding a narrow advantage in Florida. The path to victory for Mr. Romney narrowed as the night wore along, with Mr. Obama winning at least 303 electoral votes.

A cheer of jubilation sounded at the Obama campaign headquarters in Chicago when the television networks began projecting him as the winner at 11:20 p.m., even as the ballots were still being counted in many states where voters had waited in line well into the night. The victory was far narrower than his historic election four years ago, but it was no less dramatic.