Last month, the former U.S. Secretary of State John Kerry met privately with Iran’s foreign minister, Javad Zarif, on the sidelines of the Munich Security Conference, a global gathering of foreign-policy glitterati. The diplomatic odd couple once met openly and often—more with each other than with any other foreign leaders—during two years of feisty negotiations over the Iran nuclear deal. No longer. The meeting in Munich, attended by others involved in the accord, might have produced backlash in both Washington and Tehran. Kerry quietly urged the Iranians not to abandon the deal or violate its terms—whatever the Trump Administration does.

A few days later, I was in Moscow for the Valdai Discussion Club conference on the Middle East. The keynote event featured the snowy-haired Zarif and his gruffly imposing Russian counterpart, Sergey Lavrov, sitting next to each other, chummily, on white leather chairs. Both men spoke at length to diplomats and specialists from thirty countries, and then fielded questions. Afterward, they held widely covered bilateral deliberations. “The positions of Iran and Russia on many regional issues are very close,” Zarif pronounced.

What a difference a year—and a policy reversal—can make. The Trump Administration’s decision to challenge the 2015 Iran nuclear deal now carries a broad geostrategic price. The relationship between Moscow and Tehran—once tactical militarily, coldly calculating diplomatically, and practical economically—has been converted into a growing strategic partnership. Vladimir Putin’s relentless quest to make Russia a superpower again is part of it; Iran’s goal is just to be a player again. Since President Trump took office, in 2017, Moscow and Tehran have shared increasingly common bonds: growing tensions with Washington and a quest to expand spheres of influence in the Middle East.

“Two years ago, it was the United States that framed regional issues, even for Iran,” Kayhan Barzegar, the director of the Institute for Middle East Strategic Studies, in Tehran, and a former fellow at Harvard’s Belfer Center, told me in Moscow. “Now that’s over. Now it’s Russia which is very tempting to regional actors, to attach to the Russian dynamic. The U.S. produced regional confusion. Russia filled the power vacuum.”

The deepening ties were reflected when Putin flew to Tehran, in November, for talks with Supreme Leader Ali Khamenei and President Hassan Rouhani. “Our coöperation can isolate America,” Khamenei told Putin, according to Iran’s media. Putin called the growing Russian-Iran coöperation “very productive.”

Putin and Khamenei spent a highly unusual hour together, one on one, accompanied only by interpreters. “The most important thing that Putin said was, ‘I will not betray you,’ ” Ali Vaez, an Iranian-American who heads the Iran portfolio of the Brussels-based International Crisis Group, told me.

The talks came less than three weeks after Trump announced that he would not certify Iran’s compliance with the landmark nuclear deal—despite repeated reports by the U.N. nuclear watchdog, the International Atomic Energy Agency, that Tehran had consistently fulfilled its obligations. The White House is required by Congress to certify Iran’s compliance every ninety days.

Trump’s decision was a step closer to walking away from an accord negotiated by the world’s six major powers—in which the Kerry-Zarif talks were pivotal—and then formally endorsed in a unanimous U.N. Security Council resolution. In what the Times described as a “fire-breathing” speech, Trump said, in October, “We will not continue down a path whose predictable conclusion is more violence, more chaos, the very real threat of Iran’s nuclear breakout.”

Putin’s message to Khamenei was basically, You can trust us, Vaez said. We won’t renege like the Americans. “This is a pivotal moment in an evolving alliance that over the past few decades has never gone beyond a tactical relationship,” Vaez added. “It has implications across the Middle East and for the wider world.”

In January, Trump took one step further. He put Iran on notice that he would “terminate” the nuclear deal—formally known by the longwinded title of the Joint Comprehensive Plan of Action, or J.C.P.O.A.—unless it agreed to change the terms. “No one should doubt my word,” Trump said in a statement. None of the other major parties—Europe, Russia, or China—support amending the accord.

Far more than the deal is on the line, however. “The stakes are not just the J.C.P.O.A.. It’s the future of Iran,” Nasser Hadian, a U.S.-educated political scientist at Tehran University, who also taught at Columbia University, told me. “Revolutionary-ness, the fervor, may be over. But what about the mind-set of the people in the future? The U.S. is pushing us into the arms of the Russians, intentionally or unintentionally. Sometimes, we think that the U.S. prefers Iran to be in the Russian orbit than to have an independent Iran.”

Over the past year, military coördination between Moscow and Tehran has also intensified. Qassem Soleimani, the flamboyant head of Iran’s élite Quds Force, a branch of the Revolutionary Guards that is roughly equivalent to American Special Operations Forces, was the front man on military coördination between the two nations, especially in Syria, beginning in 2015. Contacts now go much higher. In November, the chief of staff of Russia’s armed forces, General Valery Gerasimov, flew to Tehran for talks with his Iranian counterpart, Major General Mohammad Bagheri, a former military intelligence expert in the Revolutionary Guards who now oversees both the Guards and the regular Iranian Army, Navy, and Air Force.

“There is good military coöperation between Iran and Russia, and, of course, there are many areas for expanding coöperation,” Bagheri declared. The two military chiefs are in increasing contact, Russian and Iranian sources told me.

Moscow and Tehran are far from natural allies. For centuries, the neighboring Russian and Persian empires were rivals. They fought a series of wars between the seventeenth and nineteenth centuries, forcing Iran to cede territories to Russia in what are today the countries of Georgia, Armenia, and Azerbaijan, plus other properties in the Caucasus and Central Asia. Russia’s occupation of Iran during the Second World War—and its refusal to leave afterward—produced the first crisis of the new U.N. Security Council. President Harry Truman’s ultimatum to Stalin to withdraw from Iran seeded the Cold War. Iran’s monarchy so feared the Communist regime that it allowed the C.I.A. to build a key listening post along the border. After its 1979 Revolution, the new Islamic Republic condemned its atheist neighbor to the north; “Neither East Nor West” became the creed of its foreign policy. The Soviet Union armed and advised Iraq during the eight-year bloodbath after Saddam Hussein invaded Iran. Moscow was as anathema as Washington. “In Iran, there’s a long history of deep distrust of the Russians,” Hadian said.

Relations improved after the Soviet Union’s demise, in 1991, though with limited and self-serving intent. A weakened Russia took over construction of a commercial nuclear reactor in the southwestern port city Bushehr, a plan first negotiated between the Shah and Germany in the nineteen-seventies. Russia’s troubled munitions industry did deals with weapons-hungry Iran, including the sale of S-300 surface-to-air missiles. But Russia was slow to deliver. The contract for Bushehr was struck in the mid-nineties, but the reactor didn’t start running until 2013. The delivery of SAM missiles, negotiated in 2007, wasn’t finalized until 2015. “Russia did not deliver on time,” Hadian noted. “But it did deliver.”

Moscow and Tehran still have differences, and their common goals have disparate motives. “Iran is important for us in Syria but also in the Caucasus and Central Asia,” Irina Zvyagelskaya, the chief research fellow at the Russian Academy of Sciences’s Institute of Oriental Studies, told me. “But that’s not to say our relationship is free of friction and tension.”

At the Valdai Club, Lavrov publicly reprimanded Iran for its rhetoric on Israel. “Allegations to the effect that, as a Zionist entity, Israel must be destroyed and wiped from the face of the Earth, are unacceptable,” he said, with Zarif sitting next to him. “This is absolutely the wrong way for someone to promote their interests.” The rebuke made headlines in Israel.