WASHINGTON — Lt. Gen. Michael T. Flynn, President-elect Donald J. Trump’s choice for national security adviser, traveled to Moscow about a year after he took charge of the Defense Intelligence Agency to cultivate what he saw as natural allies in the fight against Islamist militants: Russia’s spy agencies.

It was June 2013, a briefly optimistic moment for both the Americans and Russians, and Mr. Flynn hoped to take advantage of it. During the trip, he met with the chief of the Russian military intelligence unit known as the G.R.U. — the same agency that has since been implicated in interference in the 2016 presidential election — and held an hourlong discussion with midranking officers at its headquarters.

Relations with Moscow have soured significantly since then, yet Mr. Flynn has grown only more vehement about the need for the United States to cultivate Russia as an ally. He even returned to Moscow in 2015, a year after he was forced into retirement from the Defense Intelligence Agency, to give a paid speech for RT, the Russian English-language news organization, which American intelligence agencies have deemed a propaganda tool in the Russian election-meddling.

During that trip he also tried repeatedly to meet officers at the C.I.A’s station in Moscow — housed inside the American Embassy — to press for closer ties with Russia’s spies. But C.I.A. officers in Moscow, who have an adversarial relationship with Russia, declined to meet with him.