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.