President Barack Obama won a second term Tuesday after a fierce campaign battle, amid a struggling economy, over the role and size of the federal government.

Obama defeated the Republican ticket of Mitt Romney and Paul Ryan in a virtual sweep of key battlegrounds, including Ryan's home state of Wisconsin, which voted Democratic for the seventh presidential election in a row.

"Tonight in this election, you the American people reminded us that while our road has been hard, while our journey has been long, we have picked ourselves up, we have fought our way back, and we know in our hearts that for the United States of America, the best is yet to come," Obama told thousands of supporters gathered in Chicago.

Tuesday's election effectively insulates the president's major first-term achievements, including the new health care law, from GOP efforts to dismantle them. But it also leaves Obama limited room to build on that agenda.

Democrats kept control of the U.S. Senate, helped along by Tammy Baldwin's striking victory over Tommy Thompson in Wisconsin, one of several races in which the GOP's early expectations were crushed. Republicans maintain control of the House, ensuring a divided government -- led by many of the same key figures as before -- that has shown no ability, or even much interest, in overcoming partisan paralysis.

Obama is the third president in a row, after Republican George W. Bush and Democrat Bill Clinton, to win his re-election campaign. Unlike those two, he won with a smaller popular vote margin than he earned in his first election, grinding out a victory amid an expensive and relentlessly negative environment. In Wisconsin, for example, Obama won by single digits this time after a 14-point victory in 2008.

But Obama's victory was much more resounding in electoral terms, as he won almost all the states where both campaigns truly focused their resources. Referring to Romney, the president said: "We may have battled fiercely, but it's only because we love this country deeply, and we care so much about its future."

In his concession speech to a large crowd of supporters in Boston, Romney acknowledged his disappointment, saying: "I so wish -- I so wish that I had been able to fulfill your hopes to lead the country in a different direction."

But he said it was time to move forward.

"This is a time of great challenges for America, and I pray that the president will be successful in guiding our nation," Romney said.

Economy, health care

For Republicans nationally, the outcome will cause fierce soul-searching, since many in the party regarded Obama as hugely vulnerable amid voter discontent and economic frustration.

Ryan, the 42-year-old Janesville congressman, is one of many younger conservatives in the party who could compete to lead a GOP comeback in 2016. Yet the ticket's disappointing performance in his home state could be a political minus for him. Romney said Tuesday that Ryan, who was returned to Congress, was "the best choice I've ever made" besides his wife, Ann.

"And I trust that his intellect and his hard work and his commitment to principle will continue to contribute to the good of our nation," he said.

National exit polls showed the economy was, by a large margin, the number one issue, followed by health care and the deficit. Voters approved of Obama's performance in office, 54% to 45%, despite obvious signs of dissatisfaction.

A narrow majority, 51%, said the country was on the wrong track. Only 30% said the economy was good or excellent.

But on the economy, far more voters blamed former President George W. Bush (53%) than blamed Obama (38%).

Voters were evenly divided over whether Obama or Romney would handle the economy and the deficit better, but Obama got better marks than Romney on handling an international crisis.

In his victory speech, the president said: "You elected us to focus on your jobs, not ours. And in the coming weeks and months, I am looking forward to reaching out and working with leaders of both parties to meet the challenges we can only solve together. Reducing our deficit. Reforming our tax code. Fixing our immigration system. Freeing ourselves from foreign oil. We've got more work to do."

Romney ended up with a slightly negative image among voters: more viewed him unfavorably than favorably. And 54% said his policies favored the rich, echoing a relentless theme of Democratic attacks.

Only about a tenth of all voters said they made up their minds in the last few days of the election; about eight in 10 made up their minds before October.

The election featured big gaps by gender, age, marriage, race and ethnicity. Obama carried women by double digits, and voters under 30 by 24 points. He carried unmarried women by 38 points.

Romney carried white voters by 18 points. But Obama won black voters 93% to 6% and Hispanic voters 69% to 29%. Whites made up 72% of the electorate, down from 74% in 2008.

These are all classic partisan voting patterns, but ones that Obama had transcended in 2008 in Wisconsin, when he won independents decisively and carried Republican-leaning groups such as rural voters and white men.

Obama did not replicate the breadth of that victory this time. The profile of his Wisconsin support was closer to Democrat John Kerry's in 2004 than it was to Obama's broader coalition of 2008.

Exit polls showed Obama losing white men here by double digits, though narrowly carrying white women. They showed him losing rural whites and blue-collar whites after winning them in 2008. They showed him narrowly losing white voters overall in Wisconsin; Romney led 51% to 47%. Whites made up 86% of the vote in Wisconsin.

Obama carried the state's much smaller minority population overwhelmingly. And while Obama lost rural and suburban voters this time, he maintained huge margins among urban voters, a category that includes people living in cities of 50,000 or more.

The makeup of the electorate in Wisconsin differed in some significant ways from previous presidential elections.

The percentage of the electorate that is non-white was 14%, up from 11% in 2004, 10% in 2000 and 7% in 2000, a trend helpful to Democrats.

The share of the vote that came from union households was 21%, down from 26% in 2008, 28% in 2004 and 32% in 2000, a trend helpful to Republicans.

Democrats outnumbered Republicans in this election, 36% to 32%, with independents making up 31% of the vote, according to the exit poll. That is a smaller Democratic edge than the party had four years ago, but a much better mix for Democrats than eight years ago, when they were outnumbered by Republicans in Wisconsin.

Finally, the exit poll suggested the political center is shrinking in Wisconsin. Moderates made up 53% of the vote in 2000, 49% in 2004, 47% in 2008, but only 40% in 2012.

Lessening polarization

The 2012 campaign was marked by a record-breaking torrent of spending, much of it focused on a narrow sliver of the electorate. More than a million presidential ads were aired in the general election campaign. The vast majority of candidate travel, political organizing and television advertising was focused on just nine states: Wisconsin, Ohio, Iowa, Colorado, Nevada, Florida, Virginia, North Carolina and New Hampshire.

The Obama campaign saw Wisconsin, Ohio and Iowa as its "Midwest firewall," and that firewall did hold -- but with help from other swing states as well.

Going into election day, Romney needed to win most of the top battlegrounds to get to an electoral majority.

But Obama won at least seven of the nine, with Romney carrying only North Carolina and Florida still too close to call. Obama thanked "the best campaign team and volunteers in the history of politics -- the best ever."

Both Romney and Obama made a point to call for lessening of the polarization that has so characterized the country.

The former Massachusetts governor said: "The nation, as you know, is at a critical point. At a time like this, we can't risk partisan bickering and political posturing. Our leaders have to reach across the aisle to do the people's work. And we citizens also have to rise to the occasion."

Obama said he believes the country is not really as divided as "our politics suggests."

"We are greater than the sum of our individual ambitions, and we remain more than a collection of red states and blue states," he said. "We are and forever will be the United States of America."