WASHINGTON — Weeks before President Trump’s inauguration, his national security adviser, Michael T. Flynn, discussed American sanctions against Russia, as well as areas of possible cooperation, with that country’s ambassador to the United States, according to current and former American officials.

Throughout the discussions, the message Mr. Flynn conveyed to the ambassador, Sergey I. Kislyak — that the Obama administration was Moscow’s adversary and that relations with Russia would change under Mr. Trump — was unambiguous and highly inappropriate, the officials said.

The accounts of the conversations raise the prospect that Mr. Flynn violated a law against private citizens’ engaging in diplomacy, and directly contradict statements made by Trump advisers. They have said that Mr. Flynn spoke to Mr. Kislyak a few days after Christmas merely to arrange a phone call between President Vladimir V. Putin of Russia and Mr. Trump after the inauguration.

But current and former American officials said that conversation — which took place the day before the Obama administration imposed sanctions on Russia over accusations that it used cyberattacks to help sway the election in Mr. Trump’s favor — ranged far beyond the logistics of a post-inauguration phone call. And they said it was only one in a series of contacts between the two men that began before the election and also included talk of cooperating in the fight against the Islamic State, along with other issues.