But Justice Kennedy said the Constitution gave the president exclusive authority to determine the nation’s stance. “Put simply,” he wrote, “the nation must have a single policy regarding which governments are legitimate in the eyes of the United States and which are not.”

The nation must speak with one voice, he said, and “that voice must be the president’s.”

In dissent, Chief Justice Roberts said the majority had taken a bold step. “Today’s decision is a first,” he wrote. “Never before has this court accepted a president’s direct defiance of an act of Congress in the field of foreign affairs.”

The case concerned a 2002 law that instructed the State Department to “record the place of birth as Israel” in the passports of American children born in Jerusalem if their parents requested the designation. The law was meant to take a symbolic stand on the status of Jerusalem, which has long divided not only Israelis and Arabs but also Congress and presidents of both parties.

But the executive branch’s policy since Harry Truman’s presidency “has been to recognize no state as having sovereignty over Jerusalem, leaving the issue to be decided by negotiation between the parties to the Arab-Israeli dispute,” the Obama administration said in a brief in the case.

The case, Zivotofsky v. Kerry, No. 13-628, was brought by the parents of Menachem B. Zivotofsky, who was born not long after Congress enacted the law. Under the State Department’s policies, their son’s passport says that he was born in Jerusalem.