A friend recently challenged Harold Hongju Koh to sum up his new book, “The Trump Administration and International Law,” in three words. Koh paused for a minute and said, “He’s not winning.”

A longtime professor at and a former dean of Yale Law School, as well as the legal adviser to the State Department during Hillary Clinton’s tenure as Secretary, Koh has an improbably sunny demeanor, considering that he has devoted his career to the frequently dispiriting field of international human-rights law. His new book is written in the same optimistic vein, as he explained to a skeptical audience at New York University Law School the other day. President Trump, Koh avers, has failed in virtually every foreign-policy initiative in his first two years in office. And that, to Koh’s mind, is a fortunate thing indeed.

As Koh sees it, Trump views foreign policy as a series of deals rather than relationships. The President’s “America First” approach, Koh writes, has led to a “systematic disengagement with nearly all institutions of global governance.” But Trump has run into what Koh calls the “transnational legal process”—the series of norms, some codified in national or international law, that govern the behavior of nations. Even Trump’s bombast has not altered the “patterns of obedience” that his own country, as well as others around the world, have honored in the post–Second World War era.

Take the matter of immigration. Shortly after Trump took office, he issued a ban on travel to the United States from several predominantly Muslim countries. As Koh details in the book, there was a ferocious response from various players in the transnational legal process. Lawyers sued; individuals protested at airports and in the streets; politicians stepped forward. Some of the lawsuits succeeded, and the Trump Administration was forced to revise the ban twice, with the final version winning a narrow victory in the Supreme Court earlier this year. Koh disagrees with the Supreme Court ruling, but he notes that the Travel Ban 3.0 was a dramatically less bad rule than the original version, thanks to the legal process.

Trump’s contempt for international agreements has also limited the impact of his withdrawals from the Iran nuclear deal and from the Paris climate accord. The Iran deal was a multilateral agreement with six other countries and the European Union; only the United States has withdrawn. Iran is still honoring its commitment to suspending the development of nuclear weapons, and the other parties, in response, have begun opening up trade with it. “The other parties to the deal—the Europeans, the Russians, and the Chinese—will not default on their political obligations just because Donald Trump wants to tear the deal up,” Koh writes. The Iran deal lives on, but Trump has neutralized the ability of the United States to affect the terms of it. Likewise, with the Paris accord on climate change, Trump has announced that his Administration will leave, but, under the terms of the agreement, he cannot actually remove the United States until November of 2020—just a couple of months before the next President, as Koh hopes there will be, can bring the country back in. Meanwhile, other countries remain part of the Paris process and are (mostly) working to honor their commitments on climate change.

Trump’s blunderbuss dealings with North Korea—threats of “fire and fury” followed by what he has described as falling “in love” with the dictator Kim Jong-un—have left relations between the two nations, in Koh’s view, pretty much where they were when Trump took office. Like the past several Presidents, Trump is urging China, North Korea’s patron, to push it to limit and ultimately remove its nuclear weapons. So far, notwithstanding the high-profile summit between the two leaders in Singapore, last June, Trump doesn’t seem to be doing any better than his predecessors. The long stalemate on North Korean nukes endures.

Koh’s point is not that America’s place in the world is secure, or that our influence is positive or even benign; rather, he is simply making the case against panic and despair. Trump’s incompetence, and the resilience of domestic and international institutions, have held his worst qualities at bay. But Koh has an important caveat to the tempered optimism that characterizes his book. “We can survive four years of Trump,” Koh told the group at N.Y.U. “But I am far less confident that we can survive eight years of him.”