Americans chose to stick with a divided government in Washington, by keeping the Democratic incumbent in the White House and leaving the U.S. Congress as it is, with Democrats controlling the Senate and Republicans keeping the House of Representatives.
Romney, the multimillionaire former private equity executive, came back from a series of campaign stumbles to make it close after besting the president in the first of three presidential debates.
The 65-year-old former Massachusetts governor conceded in a gracious speech delivered to disappointed supporters at the Boston convention center. He had called Obama to concede defeat after a brief controversy over whether the president had really won Ohio.
"This is a time of great challenge for our nation," Romney told the crowd. "I pray that the president will be successful in guiding our nation."
He warned against partisan bickering and urged politicians on both sides to "put the people before the politics."
Obama scored impressive victories in the crucial state of Ohio and heavily contested swing states of Virginia, Nevada, Iowa and Colorado. They carried the Democrat past the 270 electoral votes needed for victory in America's state-by-state system of choosing a president, and left Romney's senior advisers shell-shocked at the loss.
The nationwide popular vote remained extremely close.
Obama, America's first black president, won by convincing voters to stick with him as he tries to reignite strong economic growth and recover from the worst recession since the Great Depression of the 1930s. An uneven recovery has been showing some signs of strength but the country's 7.9 percent jobless rate remains stubbornly high.
Obama's victory in the hotly contested swing state of Ohio - as projected by TV networks - was a major step in the fight for the 270 electoral votes needed to clinch the White House and ended Romney's hopes of pulling off a string of swing-state upsets.
Obama scored narrow wins in Ohio, Wisconsin, Iowa, Pennsylvania and New Hampshire - all states that Romney had contested - while the only swing state captured by Romney was North Carolina, according to television network projections.
Romney initially delayed his concession as some Republicans questioned whether Obama had in fact won Ohio despite the decisions by election experts at all the major TV networks to declare it for the president.
The later addition of Colorado and Virginia to Obama's tally - according to network projections - meant that even if the final result from Ohio were to be reversed, Romney still could not reach the needed number of electoral votes.
While Obama supporters in Chicago were ecstatic, Romney's Boston event was grim as the news was announced on television screens there. A steady stream of people left the ballroom at the Boston convention center.
THE SAME PROBLEMS
At least 120 million American voters had been expected to cast votes in the race between the Democratic incumbent and Romney after a campaign that was focused on how to repair the ailing U.S. economy.
The same problems that dogged Obama in his first term are still there to confront him again.
He faces a difficult task of tackling $1 trillion annual deficits, reducing a $16 trillion national debt, overhauling expensive social programs and dealing with a gridlocked U.S. Congress that kept the same partisan makeup.
Obama's Democrats held their Senate majority - taking hotly contested Republican-held seats in Massachusetts and Indiana - while the Republicans kept House control.
Democrat Claire McCaskill retained her U.S. Senate seat from Missouri, beating Republican congressman Todd Akin, who stirred controversy with his comment in August that women's bodies could ward off pregnancy in cases of "legitimate rape.
Democrats gained a Senate seat in Indiana that had been in Republican hands for decades after Republican candidate Richard Mourdock called pregnancy from rape something that God intended. Democratic congressman Joe Donnelly won the race.
In another high-profile Senate race, Democrat Elizabeth Warren, a law professor who headed the watchdog panel that oversaw the government's financial sector bailout, defeated incumbent Massachusetts Republican Senator Scott Brown.
Former Maine Governor Angus King won a three-way contest for the Senate seat of retiring Republican Olympia Snowe. King ran as an independent, but he is expected to caucus with Democrats in what would amount to a Democratic pick-up.
Florida Democratic Senator Bill Nelson easily beat back a challenge from Republican congressman Connie Mack to win a third term, while Democratic congressman Chris Murphy beat Republican Linda McMahon, a businesswoman who had served as chief executive of a professional wrestling company.
Democrats were also cheered by several state referendums. Maryland voters approved same-sex marriage, the governor said, and a similar measure in Maine appeared on track to pass as well - marking the first time marriage rights have been extended to same-sex couples by popular vote.
In addition, Wisconsin Democratic congresswoman Tammy Baldwin became the first openly gay U.S. Senator, defeating Republican former governor Tommy Thompson.