Barack Obama was re-elected as president on Tuesday, the television networks projected, defeating Mitt Romney after a long, hard-fought campaign that centered on who would heal the battered economy and on what role government should play in the 21st century.
The president’s official Twitter account quickly posted: “This happened because of you. Thank you.”
CBS News, CNN, Fox News and NBC News all projected that Mr. Obama would defeat Mr. Romney after concluding that he would win the necessary 270 electoral votes.
Mr. Obama carried New Hampshire and Pennsylvania and was projected by television networks to win Wisconsin, three states Mr. Romney had pursued to block Mr. Obama’s re-election.
As a succession of states fell away from Mr. Romney, a hush fell over his Boston headquarters. Advisers sounded uncharacteristically pessimistic about what they acknowledged were dwindling chances of winning an Electoral College majority.
The mood at the Obama campaign in Chicago was optimistic as the outcome of the hard-fought presidential race was dependent on Mr. Romney’s running the table in the rest of the competitive battleground states.
Americans delivered a final judgment on a long and bitter campaign that drew so many people to the polls that several key states extended voting for hours. In Virginia and Florida, long lines stretched from polling places, with the Obama campaign sending text messages to supporters in those areas, saying: “You can still vote.”
The state-by-state pursuit of the 270 electoral votes was being closely tracked by both campaigns, with Mr. Romney winning North Carolina and Indiana, which Mr. Obama carried four years ago. But Mr. Obama won Michigan, the state where Mr. Romney was born, and Minnesota, a pair of states that Republican groups had spent millions of dollars trying to make competitive.
The contests were hanging on the outcome of only a few key counties in the battleground states. In Florida, for example, the two candidates were separated by only thousands of votes out of more than six million ballots cast, with nearly 90 percent of precincts reporting.
The top issue on the minds of voters was the economy, according to interviews, with three-quarters of those surveyed saying that economic conditions were not good or poor. But only 3 in 10 said things were getting worse, and 4 in 10 said the economy was improving.
Mr. Romney, who campaigned aggressively on his ability to reverse the deepest economic downturn since the Great Depression, was given a narrow edge when voters were asked which candidate was better equipped to handle the economy, the interviews found.
The electorate was split along partisan lines over a question that has driven much of the campaign debate: whether it was Mr. Obama or his predecessor, George W. Bush, who bore the most responsibility for the nation’s continued economic challenges. Roughly half of independent voters said that Mr. Bush should be held responsible.
Americans went to the polls in makeshift voting sites in East Coast communities devastated by Hurricane Sandy and traditional voting booths set up in school gyms, libraries and town halls across the rest of the country. Even though more than 30 million Americans had already voted before Election Day, many people said they waited for hours to cast their ballots on Tuesday.
At one precinct in Prince William County, Va., election officials expected lines to remain until 10 p.m. or later. Tony Guiffre, the secretary of the elections board in the county, said hundreds of voters in line when the polls were scheduled to close at 7 p.m. were ushered inside the school and the doors were closed.
Four years after Mr. Obama drew broad support across so many categories of voters, the national electorate appeared to have withdrawn to its more familiar demographic borders, according to polls conducted by Edison Research. Mr. Obama’s coalition included support from blacks, Hispanics, women, those under 30, those in unions, gay men and lesbians and Jews.
Mr. Romney’s coalition included disproportionate support from whites, men, older people, high-income voters, evangelicals, those from suburban and rural counties, and those who call themselves adherents of the Tea Party — a group that had resisted him through the primaries but fully embraced him by Election Day.
It was the first presidential election since the 2010 Supreme Court decision loosening restrictions on political spending, and the first in which both major party candidates opted out of the campaign matching system that imposes spending limits in return for federal financing. And the overall cost of the campaign rose accordingly, with all candidates for federal office, their parties and their supportive “super PACs” spending more than $6 billion combined.
The results Tuesday were certain to be parsed for days to determine just what effect the spending had, and who would be more irate at the answer — the donors who spent millions of dollars of their own money for a certain outcome, or those who found a barrage of negative advertising to be major factors in their defeats.
While the campaign often seemed small and petty, with Mr. Romney and Mr. Obama intensely quarreling and bickering, the contest was actually rooted in big and consequential decisions, with the role of the federal government squarely at the center of the debate.
Though Mr. Obama’s health care law galvanized his most ardent opposition, and continually drew low ratings in polls as a whole, interviews with voters found that nearly half wanted to see it kept intact or expanded, a quarter wanted to see it repealed entirely and another quarter said they wanted portions of it repealed.
Even after such a bruising campaign, the interviews showed that a narrow majority of voters approved of Mr. Obama’s job performance. In an indication that his handling of the response to Hurricane Sandy helped his standing, three-fifths of those surveyed said it was a factor in their vote, and two-fifths said it was an important one.
The interviews with voters found that Mr. Obama had an edge on empathy, with somewhat more voters saying he was more in touch with people like them. A plurality said his policies generally favored the middle class, while more than half said Mr. Romney’s favored the rich.
Mr. Romney’s campaign was intently focused in the final weeks of the campaign on shaving down Mr. Obama’s at times considerable advantage among female voters, running ads emphasizing, for example, that his opposition to abortion did not extend to cases of rape or incest.
But the interviews showed that women and men continued to have starkly different views of the candidates. A majority of men said they were angry or dissatisfied with Mr. Obama’s administration; a majority of women said they were enthusiastic or satisfied with it.
As ballots were counted into the night on Tuesday, the contests in Florida, Virginia and Ohio were exceedingly close, according to early tallies and interviews with both campaigns. The 18 electoral votes of Ohio remained the central focus of the race, a key to the strategies of both sides.
As Mr. Romney gained steam and stature in the final weeks of the campaign, the Obama campaign put its hopes in one thing perhaps above all others: that the rebound in the auto industry after the president’s bailout package of 2009 would give him the winning edge in Ohio, a linchpin of his road to re-election.
Early interviews with voters showed that just over half of Ohio voters approved of the bailout, a result that was balanced by a less encouraging sign for the president: Some 4 in 10 said they or someone in their household had lost a job over the last four years.
A final and frenetic get-out-the-vote drive took place on Tuesday.
Mr. Romney, the former governor of Massachusetts, cast his vote Tuesday morning near his home in Belmont, Mass. When a reporter asked him for whom he had voted, Mr. Romney replied, “I think you know.”
Both campaigns continued trying to grind out votes on Tuesday, with Mr. Romney joining his running mate, Representative Paul D. Ryan, in Cleveland. They crossed paths with Vice President Joseph R. Biden Jr., who also wedged in one final visit to Ohio, where the 18 electoral votes are at the center of both campaigns’ strategies.
he called and thanked several startled volunteers in Wisconsin and then spoke briefly to the reporters who were traveling with him, congratulating Mr. Romney for his campaign.
“I also want to say to Governor Romney, congratulations on a spirited campaign,” Mr. Obama said. “I know that his supporters are just as engaged and just as enthusiastic and working just as hard today. We feel confident we’ve got the votes to win, that it’s going to depend ultimately on whether those votes turn out.”
As he waited to learn his fate on Tuesday, Mr. Obama conducted a round of satellite television interviews with local stations to urge his supporters to cast their ballots. Then, he continued a tradition he started four years ago of playing basketball on the afternoon of Election Day.