In December Mr. Putin, hoping for rapprochement under Mr. Trump, declined to respond to Mr. Obama’s expulsion of 35 Russian diplomatic staff members and the seizure of Russian diplomatic property. Mr. Obama said such measures were to punish Moscow for its interference in last year’s presidential election.

Mr. Putin said on Thursday that Russia had so far been “restrained and patient” in response to what he said were constant provocations by the United States. But he indicated this would not continue indefinitely. “At a certain moment we will have to respond,” he said. “It is impossible to put up forever with this boorishness toward our country.”

Mr. Putin visited Finland to help mark the 100th anniversary of its independence from the Russian empire, an occasion that allowed him to avoid the tension and street protests that often accompany his travels elsewhere in Europe.

While many European leaders give Mr. Putin a frosty reception, President Niinisto has sought to promote a spirit of quiet, steadfast cooperation between Finland and its large eastern neighbor.

Mr. Niinisto told Mr. Putin on Thursday: “I do not quite agree with you that the issue is about imposing sanctions or adhering to U.S. laws. I understand it is the suspicions about the American election process that lie behind this. That is why the United States is proposing sanctions.”

Such penalties, he said, “would have an immediate impact not only on Russia but other countries, too,” and would be the topic of discussion between the European Union and the United States. He said he agreed with Mr. Putin’s wish “that people around the world would understand each other a bit better.”

“That is in the interest of us all,” Mr. Niinisto said

Russia and Finland share an 830-mile border, and cooperation along it came under strain in 2015 at the height of Europe’s migrant crisis, when a surge of people from the Middle East, Africa and elsewhere passed through the border and sought asylum in Finland.