As I listened to President Obama’s big terrorism speech Thursday at National Defense University, I kept thinking about Jimmy Carter. Somewhere, the old man is smiling.

Since Obama assumed the presidency, hawks have been comparing him to Carter. And the analogy makes sense. In important ways, Obama’s foreign policy and Carter’s have had the same basic focus: the restoration of “solvency.” The concept comes from Walter Lippmann, who in 1943 wrote that “foreign policy consists in bringing into balance, with a comfortable surplus of power in reserve, the nation’s commitments and the nation’s power.” Just as a government cannot indefinitely incur financial commitments that exceed the money it has in the bank, Lippmann argued, it cannot indefinitely incur international commitments that exceed its national power. The longer it tries, the weaker it will get.

For Carter, the cause of this insolvency was the global Cold War. By the 1960s, George Kennan’s limited, mostly nonmilitary strategy for preventing Soviet domination of Western Europe had swelled into a commitment to stop any communist movement from gaining ground anywhere on earth, if necessary by force. And by the time Carter took office in 1977, that effort had led to Vietnam, a war that had damaged America’s economic strength, democratic system, and national morale.

Obama inherited his own solvency gap. George W. Bush had defined the Global War on Terror as a new cold war, meant to defeat jihadist terrorism, prevent nuclear proliferation, and spread democracy across the Muslim world, and beyond. Like the old cold war, it was nearly infinite in scope. And like the old cold war, it has justified military interventions that have sapped America economically, geopolitically, and morally. Since 9/11, Obama noted last Thursday, “our nation has spent well over a trillion dollars on war, exploding our deficits and constraining our ability to nation build here at home.”

Carter realized that to address his era’s solvency gap, he needed to convince Americans that their fears of communism—stoked by decades of government rhetoric—were overblown. He did so most famously in a speech on May 22, 1977, at Notre Dame, in which he declared that America was “now free of that inordinate fear of communism which once led us to embrace any dictator who joined us in that fear.” The point, which Kennan had grasped but later architects of containment had not, was that not every communist victory threatened the United States. Many Third World countries possessed neither the natural resources nor the strategic location to shift the balance of power between East and West. Even more important, local communist regimes often turned out to be more independent of—and even defiant toward—Moscow than Americans recognized. Four years after Vietnam’s communists defeated the United States, they went to war with communist China. During the 1970s, communist regimes also took power in Angola, Mozambique, Somalia, Ethiopia, South Yemen, and Afghanistan. But by decade’s end, notes the historian Odd Arne Westad, Soviet officials were privately grumbling that some of these new governments were communist in name only and perhaps more of a geopolitical burden than an asset.

Last Thursday Obama said something similar: that “we must make decisions based not on fear, but hard-earned wisdom.” Just as Carter tried to convince Americans that not every movement or regime that called itself communist menaced America, Obama insisted that “not every collection of thugs that labels themselves al Qaeda will pose a credible threat to the United States.” The point, which Kennan had made in vain as containment swelled, was that broad ideological labels often obscure local agendas and interests. And when America forgets that, as it did in Vietnam, and has more recently in Afghanistan, it often charges off to fight some global ideological foe only to find that its real enemy is a small nation or tribe fighting to keep us off their patch of land.

Finally, Obama—like Carter—argued that America’s solvency gap was not only damaging it economically, but ethically as well. The global cold war had created what Arthur Schlesinger Jr. called “the imperial presidency,” an executive branch empowered to topple governments abroad and harass critics at home with barely any congressional oversight. Taking office in the wake of Watergate, Carter promised that by no longer seeing itself as engaged in a global, near-permanent Cold War, America would no longer be “tempted to employ improper tactics here and abroad” and would find “our way back to our own principles and values.” For his part, Obama said that in its post-9/11 treatment of detainees, America had “compromised our basic values” and that “this war, like all wars, must end,” because “that’s what our democracy demands.”

But if Carter and Obama both wanted to bring America’s external commitments back in line with its domestic resources, there is one critical difference: Obama is not destroying his presidency in the process. By 1979, Carter’s bid to end the global Cold War had become a political disaster. In November 1979, militants from the newly established Islamic Republic of Iran took scores of Americans hostage. Weeks later, the Soviet Union invaded Afghanistan. For hawks, the lesson was clear: in trying to end the Cold War, Carter was instead losing it.

That claim—which the right has repeated ever since—has little basis in fact. Yes, Iran’s Islamic Revolution dealt a blow to the United States, but it hardly empowered the U.S.S.R. Tehran’s nascent theocracy was anti-communist as well as anti-American and even helped inspire the mujahedin rebels who took up arms against the Soviet-backed government in Afghanistan. And by sending 85,000 troops to bolster its Afghan ally, Moscow wasn’t gaining an edge in the Cold War, it was disastrously exacerbating its own solvency gap. By 1979, Soviet agriculture was in such disrepair that the country had become a net importer of grain, and the U.S.S.R. was suffering shortages of medicine, soap, toothpaste, and thread. In the United States, hawks obsessed about the Soviet Union’s growing global footprint without recognizing that Moscow’s commitments overseas were only exacerbating its economic crisis at home, a crisis that within a decade would bring the Soviet empire crashing down.

But none of this helped Jimmy Carter. Still traumatized by their defeat in Vietnam, Americans had little tolerance for the new humiliation in Iran. America’s setbacks overseas, warned Carter’s national-security adviser, Zbigniew Brzezinski, “are creating the conditions for domestic reaction.” He was right. Combined with economic “stagflation” at home, Carter’s perceived failures abroad destroyed his presidency and brought Ronald Reagan to power.

Ever since Obama took office, hawks have been hoping he would suffer the same fate. But unlike Carter’s policies, Obama’s efforts to reduce America’s commitments abroad have not become a political vulnerability at home. Part of it is luck. In 1979 the overthrow of an American client in the Middle East produced an agonizing hostage crisis. Today, despite the murders in Benghazi, Libya, the revolutions against U.S.-backed leaders like Hosni Mubarak have been nowhere near as traumatizing.

But Obama has also been shrewder than Carter. Even as he has wound down the Global War on Terror, he has understood the importance of looking and sounding like a hawk. It began when he named a Republican, Robert Gates, and a Marine general friendly with Republicans, James Jones, to two of his top national-security jobs. It continued when he sent 30,000 more troops to Afghanistan in late 2009, a decision that was morally dubious but politically shrewd since it avoided a showdown with the then–wildly popular David Petraeus. By the time the surge ended, the war in Afghanistan was so widely discredited that even Mitt Romney endorsed Obama’s decision to pull the plug. Finally, and most importantly, Obama killed Osama bin Laden, thus avenging 9/11 and giving him a devastating all-purpose rejoinder to Republican claims that he’s insufficiently tough on terror.

Obama has benefited from facing a Republican Party whose foreign policy credibility George W. Bush massively squandered. Still, what he’s accomplished politically is downright historic. After Harry Truman “lost” China to the communists, he spent the rest of his term on the defensive against the McCarthyite mob. Lyndon Johnson felt certain that if he “lost” South Vietnam, he’d suffer the same fate. When Carter “lost” Iran, it helped lose him the presidency. Yet Obama—a liberal Democrat with no military experience—is ending two real wars and one conceptual one without being able to claim victory in any of them. And the best his Republican opponents can do is moan about Benghazi.

Obama’s foreign policy hasn’t been perfect. But his basic goal of bringing America’s overseas commitments back into balance with our power has been absolutely right. And most remarkably of all, he’s actually pulling it off.