WASHINGTON (AP) -- The Supreme Court has upheld the nationwide tax subsidies under President Barack Obama's health care overhaul, in a ruling that preserves health insurance for millions of Americans.

The justices said in a 6-3 ruling Thursday that the subsidies that 8.7 million people currently receive to make insurance affordable do not depend on where they live, under the 2010 health care law.

The outcome is the second major victory for Obama in politically charged Supreme Court tests of his most significant domestic achievement.

Chief Justice John Roberts again voted with his liberal colleagues in support of the law. Roberts also was the key vote to uphold the law in 2012.

Justice Anthony Kennedy also voted with his more liberal colleagues.

Most Americans (56 percent) would prefer that the court rule in favor of the Obama administration, allowing the government to continue subsidizing premiums in all states, according to an April Associated Press-GfK poll. On the other side, 39 percent would prefer that the court rule for the plaintiffs who brought the case, who say that the literal wording of the law limits the government to subsidizing premiums in states that have set up their own health insurance exchanges, rather than relying on the federal government exchange.

Nearly three-quarters of Democrats and a slim majority of independents want the court to rule in favor of the government, while a majority of Republicans want the court to limit insurance subsidies under the law to states with their own exchanges.

Among people who oppose the health care law generally, 58 percent want the court to limit the government to subsidizing premiums only in states with exchanges. But a significant minority of the law's opponents (39 percent) think the court should rule that the government can continue to subsidize premiums in all states.

In the April AP-GfK poll, just 13 percent of Americans said they were following news about the health care case extremely or very closely, while 60 percent said they were not following the case closely.

Likewise, a Kaiser Family Foundation poll conducted in June found that 44 percent of Americans had heard nothing at all about the case, and 28 percent had heard only a little.

That's true even though the vast majority of Americans, 78 percent, called health care a very or extremely important issue in the AP-GfK poll.

In general, the April AP-GfK poll found that 27 percent of Americans support and 38 percent oppose the 2010 health care law, while 34 percent are neither in favor nor opposed.

But there is a significant partisan divide over the law, with 52 percent of Democrats supporting the law, but only 11 percent of independents and just 5 percent of Republicans saying the same.

The poll found 44 percent of Americans approved and 55 percent disapproved of the way Obama is handling health care. But more Americans trust the Democratic Party than the Republican Party on handling the issue, 34 percent to 24 percent.

The AP-GfK Poll of 1,077 adults was conducted online April 23-27, using a sample drawn from GfK's probability-based KnowledgePanel, which is designed to be representative of the U.S. population. The margin of sampling error for all respondents is plus or minus 3.4 percentage points.

Respondents were first selected randomly using phone or mail survey methods, and later interviewed online. People selected for KnowledgePanel who didn't otherwise have access to the Internet were provided access at no cost to them.