One of the sharpest and most telling differences on foreign policy between Barack Obama and John McCain is whether the United States should talk to difficult and disreputable leaders like Iran's Mahmoud Ahmadinejad or Venezuela's Hugo Chávez. In each of the three presidential debates, McCain belittled Obama as naive for arguing that America should be willing to negotiate with such adversaries. In the vice presidential debate, Sarah Palin went even further, accusing Obama of "bad judgment … that is dangerous," an ironic charge given her own very modest foreign-policy credentials.

Are McCain and Palin correct that America should stonewall its foes? I lived this issue for 27 years as a career diplomat, serving both Republican and Democratic administrations. Maybe that's why I've been struggling to find the real wisdom and logic in this Republican assault against Obama. I'll bet that a poll of senior diplomats who have served presidents from Carter to Bush would reveal an overwhelming majority who agree with the following position: of course we should talk to difficult adversaries—when it is in our interest and at a time of our choosing.

The more challenging and pertinent question, especially for the McCain-Palin ticket, is the reverse: Is it really smart to declare we will never talk to such leaders? Is it really in our long-term national interest to shut ourselves off from one of the most important and powerful states in the Middle East—Iran—or one of our major suppliers of oil, Venezuela?

During the five decades of the cold war, when Americans had a more Manichaean view of the world, we did, from time to time, cut off relations with particularly odious leaders such as North Korea's Kim Il Sung or Albania's bloodthirsty and maniacal strongman, Enver Hoxha. But for the most part even our most ardent cold-war presidents—Dwight Eisenhower, John Kennedy, Richard Nixon and Ronald Reagan, none of whom was often accused of being weak or naive—decided that sitting down with our adversaries made good sense for America. They all talked to Soviet leaders—men vastly more threatening to America's survival than Ahmadinejad or Chávez are now. JFK negotiated a nuclear Test-Ban Treaty with his mortal adversary, Nikita Khrushchev, just one year after the two narrowly avoided a nuclear holocaust during the Cuban missile crisis. Perhaps more dramatically, Nixon, the greatest anticommunist crusader of his time, went to China in 1972 to repair a more than 20-year rupture with Mao Zedong that he believed no longer worked for America.

All of these cold-war presidents embraced a foreign-policy maxim memorialized by one of the toughest and most experienced leaders of our time, Israel's Yitzhak Rabin, who defended his discussions with Yasir Arafat by declaring, "You don't make peace with friends, you make peace with very unsavory enemies." Why should the United States approach the world any differently now? Especially now? As Americans learned all too dramatically on 9/11 and again during the financial crisis this autumn, we inhabit a rapidly integrating planet where dangers can strike at any time and from great distances. And when others—China, India, Brazil—are rising to share power in the world with us, America needs to spend more time, not less, talking and listening to friends and foes alike.

The real truth Americans need to embrace is that nearly all of the most urgent global challenges—the quaking financial markets, climate change, terrorism—cannot be resolved by America's acting alone in the world. Rather than retreat into isolationism, as we have often done in our history, or go it alone as the unilateralists advocated disastrously in the past decade, we need to commit ourselves to a national strategy of smart engagement with the rest of the world. Simply put, we need all the friends we can get. And we need to think more creatively about how to blunt the power of opponents through smart diplomacy, not just the force of arms.

Talking to our adversaries is no one's idea of fun, and it is not a sure prescription for success in every crisis. But it is crude, simplistic and wrong to charge that negotiations reflect weakness or appeasement. More often than not, they are evidence of a strong and self-confident country. One of America's greatest but often neglected strengths is, in fact, our diplomatic power. Condoleezza Rice's visit to Libya in September—the first by a U.S. secretary of state in five decades—was the culmination of years of careful, deliberate diplomacy to maneuver the Libyan leadership to give up its weapons of mass destruction and renounce terrorism. She would not have achieved that victory had she refused to talk to the Libyans.

For sure, a successful diplomacy needs to be backed up by strong military and intelligence services to fight our wars and terrorist groups like Al Qaeda. We should constantly remind our adversaries that we have other options, including the possible use of force, if talks fail. But we have put too many of the world's problems on the shoulders of our generals and intelligence officers when diplomacy—our ability to persuade, cajole or threaten an opponent—is sometimes the better and more effective way to proceed. We need to trust our ability to outmaneuver dangerous regimes at the negotiating table and in the high court of international public opinion.

Iran is a case in point. Its hard-line, theocratic government poses the greatest threat to peace in the Middle East today. It is funding and arming most of the region's terrorist groups shooting at us, Israel and our moderate Arab friends. It has complicated our efforts in Iraq and Afghanistan. Most alarming, Iran is seeking a nuclear-weapons capability that would change the balance of power in the Middle East.

Rather than default to the idea of using U.S. military force against Iran, wouldn't it make more sense for the next American president to offer to negotiate with the Iranian leadership? Here's the logic. If the talks end up succeeding, we will have prevented a third, and potentially catastrophic, war for the United States in the volatile area linking the Middle East and South Asia. If the talks fail, we will have a far better chance of persuading Russia and China to sign on to tougher sanctions against Iran. I think war with Iran would be unconscionable if we refuse even to try diplomacy first.

I'm not saying the next president should sit down immediately with Ahmadinejad. We should initiate contact at a lower level to investigate whether it's worth putting the president's prestige on the line. We should leave the threat of military action on the table to give us greater leverage as we talk to the Iranian government. And ultimately we'd want other countries with influence—like Russia and China—to sit on our side of the table in order to bring maximum pressure to bear against Tehran. But the United States hasn't had a meaningful set of talks with Iran on all the critical issues that separate us in 30 years, since the Khomeini revolution. To illustrate how far we have isolated ourselves, think about this: I served as the Bush administration's point person on Iran for three years but was never permitted to meet an Iranian. To her immense credit, Secretary Rice arranged for my successor to participate in a multilateral meeting with Iranian officials this past summer. That is a good first step, but the next American president should initiate a more sustained discussion with senior Iranians.

If we aren't willing to talk to Iran, we may leave ourselves with only one option—military action. The next U.S. president will have little chance of securing peace in the Middle East if he doesn't determine Iran's bottom line on the nuclear issue through talks. Similarly, there will be no peace treaty between Syria and Israel if we don't support the talks underway between those countries.

In Afghanistan, the new president will face a very difficult set of choices roughly similar to those in Iraq before the surge. The brilliance of Gen. David Petraeus's strategy in Iraq was, in part, to build bridges to formerly bitter foes in the Sunni militias and to cajole and entice them to switch sides. Some are now suggesting that we should deploy a similar strategy with the Taliban rank and file.

While we should have absolutely no interest in sitting down with Qaeda fanatics or the Taliban leadership, does it make sense to try to persuade lower-ranking Taliban supporters to give up the armed struggle and commit to a democratic Afghanistan? While that's a seemingly logical goal, it would be highly problematic in the short term. We would be better served if we first built up a position of much greater military and political strength, and increased security for Afghan villagers. Talking to our adversaries is not always the answer to all our problems, especially in a highly complex environment such as Afghanistan. We have a long way to go before it might be part of a long-term solution there.

America faces a complex and difficult geopolitical landscape. The next president needs to act more creatively and boldly to defend our interests by revalidating diplomacy as a key weapon in our national arsenal and rebuilding our understaffed and underfunded diplomatic corps. Of course he will need to reserve the right to use force against the most vicious and implacable of our foes. More often than not, however, he will find that dialogue and discussion, talking and listening, are the smarter ways to defend our country, end crises and sometimes even sow the seeds of an ultimate peace.