Putin made the comments on a one-day trip to Tehran for trilateral talks between Azerbaijan, Iran and Russia, a meeting largely focused on improving road and rail links to the neighboring countries on the Caspian Sea.
However, the nuclear deal loomed large as Putin met with both Iranian President Hassan Rouhani, who easily won re-election this year after securing the atomic deal, and Supreme Leader Ayatollah Ali Khamenei, who has the final say on all state matters.
"We oppose any unilateral change in the multilateral nuclear deal," Putin said while meeting Khamenei, according to a statement from the supreme leader's office. "We oppose linking Iran's nuclear program with other issues including defensive issues."
Moscow has stood by Tehran while Trump has refused to re-certify the nuclear deal between Iran and world powers, including Russia. The other parties to the accord - Britain, China, France, Germany and the European Union - have also urged Trump to stay in the deal.
The U.S. Congress now will make a decision regarding the 2015 nuclear deal, in which Iran agreed to limit its enrichment of uranium in exchange for the lifting of economic sanctions. In recent days, lawmakers have targeted Iran with new sanctions over its ballistic missile program, which wasn't included in the deal but which American officials say violates the spirit of the accord.
Khamenei praised Putin's "strong" character.
"Because of this reason, it is possible to have logical dialogue and cooperation with Russia as a big power about big jobs that require determination and effort," the supreme leader said.
Russia and Iran have a complicated history. Many still remember how Russia, alongside Britain, invaded and occupied Iran during World War II to secure oil fields and Allied supply lines.
But while Britain withdrew, Russia refused to leave, sparking the first international rebuke by the nascent U.N. Security Council in 1946. During the Soviet occupation of Afghanistan, Iran allowed refugees into the country and backed mujahedeen rebel fighters - as did the U.S. and Saudi Arabia.
While Gulf Arab states sought the protection of the U.S. after the 1991 Gulf War, Iran tilted toward Russia. Russia has supplied surface-to-air missiles to Iran, and helped it to build its first nuclear power plant, in the southern port city of Bushehr, which went online in 2011. The two countries are now partnering in the construction of two more nuclear reactors at the site.
Russia and Iran have both provided crucial support to President Bashar Assad's forces in the Syrian civil war, something Rouhani praised during his meeting with Putin.
"Iranian and Russian cooperation has had a great impact in fighting terrorism in the region," Rouhani said, according to a statement from his office. "The joint cooperation and consultations are very important in the final stages too."
Iran allowed Russia access to its air bases last year to bomb targets in Syria. But that struck a nerve in Iran, whose constitution bars foreign militaries from having bases in the country.
Russia has reached out to Saudi Arabia in recent weeks, promising weapons systems and other investments to the ultraconservative Sunni kingdom. That too has raised eyebrows in Shiite Iran, which is the kingdom's Mideast rival.
Prior to Putin's arrival on his third trip to Iran, Russia's armed forces chief, Gen. Valery Gerasimov, met with his Iranian counterpart, Gen. Mohammad Hossein Bagheri, and discussed defense and security issues, Iranian state television reported on Wednesday, without elaborating.
Tehran-based political analyst Saeed Leilaz said Putin's visit to Tehran could lead to more investment in the oil industry and other infrastructure projects that "may encourage European and Chinese and even American companies to enter the Iranian market."
Associated Press writer Jon Gambrell in Dubai, United Arab Emirates, contributed to this report.
Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.