MOSCOW — President Vladimir V. Putin called President Trump on Sunday to thank him for the work of the Central Intelligence Agency in helping prevent an Islamic State attack in the northern Russian city of St. Petersburg.

In rare words of praise for the C.I.A., Mr. Putin said the agency had provided information that “helped detain terrorists planning explosions,” the Kremlin said in a statement posted on its website. The attackers planned to strike crowded sites including Kazan Cathedral, a landmark Orthodox Christian church, the statement said.

“The information received from the C.I.A. was sufficient to search for and detain criminals,” the statement said. “The head of the Russian state asked the American president to convey words of thanks to the director of the C.I.A. and the American intelligence officers who received this information.”

The attack was described as imminent. It was said to be planned for Sunday — just two days after the first arrests were made on Friday. It was not clear when the C.I.A. provided the tip.