Diplomats brushed aside what appeared to be a hastily organized pressure campaign by the White House, including last-minute threats by President Trump to cut off aid to countries voting for the resolution.
“We will not be threatened,” Mr. Malki, one of several diplomats who spoke before the vote, told the General Assembly at an emergency meeting. He said the United States had insisted on “ignoring the dangerous repercussions of its decision.”
The Israeli government was equally defiant in the run-up to the vote. Prime Minister Benjamin Netanyahu of Israel, speaking at the dedication of a new hospital in the city of Ashdod, declared that “Jerusalem is the capital of Israel, whether the U.N. recognizes it or not.”
The outcome, which many diplomats said privately was a foregone conclusion, deepened Mr. Trump’s isolation over the issue, threatened to alienate Arab allies of the United States and may have further complicated prospects for a two-state solution to the Israeli-Palestinian conflict.
The vote also reflected resentment toward threats by Mr. Trump and his ambassador to the United Nations, Nikki R. Haley. They had warned that any country supporting the resolution risked a cutoff in aid.
Ms. Haley amplified those threats in her speech before the vote, suggesting the United States, the biggest single contributor to the United Nations budget, may reduce its largess going forward.
President Trump’s decision, she said, “reflects our right as a nation to choose the location of our embassy.”
“The United States will remember this day in which it was singled out for attack in the General Assembly,” Ms. Haley said. “We will remember it when called upon once again to make the largest contribution to the United Nations.”
The willingness of other countries to ignore or play down such threats suggested they had concluded that Mr. Trump was making them for domestic political reasons. It is also difficult to see how he could make good on a vow to cut financial assistance to important allies like Egypt, Iraq and Jordan.
Nonetheless, the overwhelming rejection of the American shift of position on Jerusalem, on the world’s biggest diplomatic stage, was a setback for a president who is still looking for a major foreign achievement after nearly a year on the job.
Carrying out a promise to his base of supporters, Mr. Trump upended decades of American policy with the decision on Jerusalem, aggravating an emotional issue that has festered since the 1967 Arab-Israeli war when the Israelis occupied the entire city.
Many Security Council resolutions since then, which have the force of international law, have warned that Jerusalem’s status is unresolved, that claims of sovereignty by Israel are invalid and that the issue must be settled in negotiations between the Israelis and Palestinians.
The General Assembly resolution does not mention the United States by name, but it calls for a “reversal of the negative trends on the ground that are imperiling the two-state solution.”
It also demanded that all states comply with the resolutions concerning Jerusalem and called upon them to “refrain from the establishment of diplomatic missions” there.
The General Assembly resolution was introduced a few days after a nearly identical resolution in the 15-member Security Council had been vetoed by the United States — the lone no vote — an outcome that stoked Mr. Trump’s anger.
“All of these nations that take our money and then they vote against us at the Security Council or they vote against us, potentially, at the Assembly, they take hundreds of millions of dollars and even billions of dollars and then they vote against us,” Mr. Trump said on Wednesday.
“Well, we’re watching those votes,” he said. “Let them vote against us; we’ll save a lot. We don’t care.”
On Tuesday Ms. Haley sent an email to General Assembly members, urging them to back the United States on the issue.
She argued that Mr. Trump’s Jerusalem declaration had not prejudged the outcome of any negotiations and “does not foreclose any of the options considered by Israelis and Palestinians for decades.”
But she also invoked a threat by Mr. Trump, writing: “The President will be watching this vote carefully and has requested I report back on those countries who voted against us. We will take note of each and every vote on this issue.”
It was not the first time that Ms. Haley had used this language at the United Nations. Soon after taking her post in January, she said, “You’re going to see a change in the way we do business.” The United States, she said, would back its allies and expected their backing in return. “For those who don’t have our back,” she added, “we’re taking names.”