Information provided by the CIA helped Russian security services foil an attack on St Petersburg's Kazan cathedral, the Kremlin says.
The attack was allegedly planned to take place on Saturday, officials say.
In a phone call, President Vladimir Putin thanked Donald Trump for the CIA's intervention, the Kremlin said.
Putin told Trump that Russia's special services would hand over information on terror threats to their US counterparts, it added.
Russia's FSB security service said in a statement on Friday that it had detained seven members of a cell of Islamic State supporters and seized a significant amount of explosives, weapons and extremist literature.
The cell was planning to carry out a suicide attack at a religious institution and kill citizens on Saturday, the FSB statement said (in Russian).
The group was preparing explosions targeting the cathedral and other public places in Russia's second city, the Kremlin statement said.
It added that Putin had asked the US president to pass on his thanks to the CIA director and the operatives involved.
US intelligence agencies, including the CIA, believe that Russia tried to sway last year's US presidential election in favour of Trump - claims rejected by the Republican.
A special counsel is investigating whether anyone from the Trump campaign colluded.
Sunday's conversation between the two presidents marks the second time the two men have spoken in a week.
On Thursday they discussed North Korea and Trump thanked Putin "for acknowledging America's strong economic performance" in his annual press conference, according to the White House.
White House press secretary Sarah Sanders confirmed that Trump and his Russian counterpart had spoken on Sunday. More details are expected soon.
An explosion on St Petersburg's metro system in April killed at least 13 people and is thought to be linked to jihadists.
Returning militants from Syria pose a real threat to Russia, the head of the FSB was quoted as saying on Tuesday.
Security services had already prevented 18 terrorist attacks in 2017, Alexander Bortnikov said in comments reported by Itar-Tass news agency.