The world just did to Donald Trump the one thing that he hates more than anything—it disrespected him. The odd thing is, he could have avoided the humiliation if only he knew a little about international relations or valued what his advisers tried to teach him above his most craven political instincts.

On Thursday afternoon, the U.N. General Assembly voted 128–9 (with 35 member states abstaining) to declare null and void the United States’ recent recognition of Jerusalem as the capital of Israel—a recognition that Trump had bestowed on Dec. 6. The U.N. vote has no binding effect, but it is a loud rebuke of Trump, just three days after he boasted that he had restored the world’s respect for American leadership.

The rebuke is amplified by the fact that Trump had announced the day before that he would revoke financial aid for any country that voted for the resolution. “Let them vote against us,” he said at a cabinet meeting on Wednesday. “We’ll save a lot. We don’t care. But this isn’t like it used to be where they could vote against you and then you pay them hundreds of millions of dollars. We’re not going to be taken advantage of any longer.”

Trump’s U.N. ambassador, Nikki Haley, wrote a letter to other delegates, warning, “The U.S. will be taking names” during the roll call. “As you consider your vote,” she elaborated, “I encourage you to know the president and the U.S. take this vote personally. She then tweeted, “At the UN we’re always asked to do more and give more. So, when we make a decision, at the will of the American ppl, abt where to locate OUR embassy, we don’t expect those we’ve helped to target us.”

It is doubtful that Trump will follow through on this threat—which will make him look still more petulant—but if he does take action, it will severely damage U.S. interests, even as he has defined them.

The countries that voted for the resolution— or, as Trump sees it, against him—include four of the five biggest recipients of U.S. aid: Afghanistan, Iraq, Egypt, and Jordan. They also include countries that Trump has courted since taking office—Saudi Arabia, Russia, China, India, Pakistan, and Vietnam. They also include every country in Western Europe, though Trump might not care about that.

It would be one thing if all these countries publicly razzed America on some vital national interest—something to do with, say, al-Qaida or ISIS or a cyberattack on our elections. But a declaration about the capital of Israel does not meet that standard.

The fact is, no other countries recognize Jerusalem as the capital of Israel; though 10 countries, including the U.S., have diplomatic missions of some sort in the city, they are separate from their embassies, which are in Tel Aviv. Ever since 1967, the U.S. State Department has considered East Jerusalem as “occupied territory.” American policy, like that of many countries, has stated that the status of Jerusalem will be determined as part of a broader Israeli-Palestinian peace treaty. To declare the matter settled is, in effect, to discard the long-standing goal of a “two-state” solution to the conflict.

Neither Trump nor any of his officials have disputed any of these facts. Secretary of Defense James Mattis was asked during his Senate confirmation hearings whether he considered Jerusalem to be Israel’s capital. He demurred, saying he’d stick with the long-standing policy of regarding the capital as Tel Aviv.

Just after Trump announced his Jerusalem gambit, David Satterfield, the acting assistant secretary of state for Near Eastern affairs, held a news conference. One of the most intriguing exchanges went as follows:

QUESTION: And one other question. Do you regard those portions of East Jerusalem that were occupied by Israel in 1967 as occupied territory?

AMBASSADOR SATTERFIELD: The decision of the President is to recognize Jerusalem as the capital of the state of Israel. The President has stated that that decision does not touch upon issues of boundaries, of sovereignty, or geographic borders. Full stop.

QUESTION: So it is still occupied territory, in your view?

AMBASSADOR SATTERFIELD: I have stated what the President’s decision does and does not do.

QUESTION: What is the current policy of the U.S. administration towards Israeli settlements in East Jerusalem?

AMBASSADOR SATTERFIELD: As—this decision had no impact on any issue other than the recognition or acknowledgment of Jerusalem as the capital of Israel.

Satterfield, a veteran diplomat with Middle Eastern postings under Republican and Democratic presidents, knew the absurdity of Trump’s position. Mattis and other briefers, as well as several Arab officials with whom Trump has good relations, had cautioned the president that recognizing Jerusalem would have major diplomatic consequences and could spark protests and violence throughout the region and possibly the world.

Hence the U.N. vote on Thursday. Trump was warned that something like this would happen. In the runup, not only did he fail to take steps that might have softened the blow, he did everything he could to harden it—he cranked up the rhetoric, he ratcheted up the stakes.

And he did this for no need. The fact is, the status of Jerusalem is no longer the hot-button issue that it once was. The region’s Arab leaders—especially in Saudi Arabia, Egypt, and Jordan—have turned their focus on the expansionism of Iran. In that struggle, they see Israel as an ally—even if they don’t publicly acknowledge this alliance—and they don’t want to upset that arrangement by harping on the Palestinians.

By raising Jerusalem as an issue, Trump put it back on the front burner of the region’s politics. Whatever the Sunni Arabs’ real feelings about the nature of a future Palestinian state, they can’t go along with a policy that would block the formation of such a state—which is what Trump’s declaration does. Even if they don’t care personally, they know that acceding to such a policy would rile the anger of their citizens. Once Trump declared that he was recognizing Jerusalem as Israel’s capital, the Arab leaders had to oppose it.

On Monday, the issue came before the U.N. Security Council, which voted 14–1 to declare the U.S. recognition as null and avoid—but the sole dissent was cast by the United States, which, as a permanent member of the Council, has veto power. So the resolution was rejected. At that point, Yemen and Turkey—the latter a member of NATO—brought the matter before the General Assembly. Anyone would have seen that the measure would win overwhelming support by allies and adversaries alike. Yet rather than ignore or wave away the results, Trump aimed the spotlight right on it, threatening those who voted against his preference.

The vote took place just three days after Trump issued a 55-page document on a National Security Strategy, which warns of a coming cold war with Russia and China—and possible hot wars with North Korea and Iran. If any of these tensions escalate, he will need allies in Europe, Asia, and the Middle East. Yet with his fuss over Thursday’s U.N. vote—on a nonbinding resolution, over an issue that has no vital interest for the United States, an issue that’s entirely one of theatrics—Trump has managed to alienate all of those allies.

The curious thing is that not even Trump seems to have taken his policy shift on Jerusalem very seriously. After making his announcement on Dec. 6, he signed the congressionally mandated waiver that permits a president to keep the U.S. embassy in Tel Aviv for another six months. Secretary of State Rex Tillerson has said it will take at least three years to move the embassy from Tel Aviv to Jerusalem. The U.S. already has a consulate in Jerusalem, and key personnel could move there and anoint it an “embassy” within days if the president wanted them to do so.

Clearly, Trump made his move as a domestic political ploy to please a portion of his “base,” namely, the most conservative American Jews—including his ambassador to Israel, who opposes all restrictions on Jewish settlements—and certain Christian evangelicals. In other words, he made an unwise decision, which has further isolated the United States, for the shallowest of reasons—and now he could make an even worse decision because he’s humiliated.

This is the status of American leadership in the age of Trump.