WASHINGTON — The Supreme Court on Thursday upheld President Obama’s health care overhaul law, saying its requirement that most Americans obtain insurance or pay a penalty was authorized by Congress’s power to levy taxes. The vote was 5 to 4, with Chief Justice John G. Roberts Jr. joining the court’s four more liberal members.

The decision was a victory for Mr. Obama and Congressional Democrats, affirming the central legislative achievement of Mr. Obama’s presidency.

“The Affordable Care Act’s requirement that certain individuals pay a financial penalty for not obtaining health insurance may reasonably be characterized as a tax,” Chief Justice Roberts wrote in the majority opinion. “Because the Constitution permits such a tax, it is not our role to forbid it, or to pass upon its wisdom or fairness.”

At the same time, the court rejected the argument that the administration had pressed most vigorously in support of the law, that its individual mandate was justified by Congress’s power to regulate interstate commerce. The vote was again 5 to 4, but in this instance Chief Justice Roberts and the court’s four more conservative members were in agreement.