– Rinat Akhmetshin, a Russian immigrant who met last summer with senior Trump campaign officials, has often struck colleagues as a classic Washington mercenary — loyal to his wife, his daughter and his bank account. He avoided work that would antagonize Moscow, they suggested, only because he profited from his reputation as a man with valuable connections there.

But interviews with his associates and documents reviewed by the New York Times indicate that Akhmetshin, who is under scrutiny by the special counsel Robert S. Mueller III, has much deeper ties to the Russian government and Kremlin-backed oligarchs than previously known.

He has an association with a former deputy head of a Russian spy service, the FSB, and a history of working for close allies of President Vladimir Putin. Twice, he has worked on legal battles for Russian tycoons whose opponents suffered sophisticated hacking attacks, arousing allegations of computer espionage. He helped federal prosecutors bring corruption charges against an American businessman in the former Soviet Union who turned out to be working for the CIA.

He also helped expose possible corruption in government contracting that complicated U.S. efforts to keep troops at an air base in Kyrgyzstan — an American presence that the Russians fiercely opposed.

In short, Akhmetshin’s projects over two decades in Washington routinely advanced the Kremlin’s interests, especially after he became a U.S. citizen in 2009. U.S. counterintelligence agents took notice of his activities, but drew no conclusions about where his allegiances lay, according to a former law enforcement official who spoke on condition of anonymity, citing government secrecy rules.

Akhmetshin’s meeting with Trump campaign officials is of keen interest to Mueller, who is investigating the Kremlin’s efforts to interfere in the 2016 election. Of all the visitors who attended the June 2016 session at the Trump Tower, he appears to have the most direct ties to Russian intelligence. The session was arranged by a Russian businessman close to Putin whose emissary promised damaging information about Hillary Clinton as “part of Russia and its government’s support for Mr. Trump.”

Akhmetshin, who did not respond to repeated requests to be interviewed for this article, has said he was a last-minute guest at an inconsequential get-together. Trump campaign officials have dismissed the meeting as part of an effort to amend a U.S. law that placed sanctions on Russians for human rights abuses. The 2012 law, known as the Magnitsky Act, infuriated Putin, whose government retaliated by restricting adoptions of Russian children by Americans.

Ronald J. McNamara, a former staff member of the U.S. Commission on Security and Cooperation in Europe who met with Akhmetshin about Central Asian issues, said Akhmetshin openly alluded to involvement with Russian intelligence. “My understanding was that he had come from the security agencies in the Soviet Union-Russian Federation,” McNamara said. “He did not make it a secret.”

Akhmetshin, 49, said he is no Russian spy. “I am the target of a well-coordinated and financed smear campaign,” he said last month in a text message to The Times.

Keenly intelligent, relentlessly charming and assiduously opaque about his work, Akhmetshin sometimes referred to his contacts by pseudonyms and collected his salary in stacks of hundred-dollar bills. A trained biochemist who speaks four languages, he described himself on one official document as a “househusband.” He identified himself as the head of a Washington think tank for years after it was officially dissolved.

“I think he works for us. I don’t think he works for them,” said Lanny Wiles, a veteran Republican political operative who has worked with Akhmetshin for more than 15 years. “But I don’t know what he really does.”

Rise of an influence peddler

Born in Kazan, Russia, about 500 miles west of Moscow, Rinat Rafkatovitch Akhmetshin was drafted at age 18 into the Soviet army’s war against Afghanistan. He served from 1968 to 1988 and again in 1991. He described himself on his visa application for the U.S. as a sergeant who rose to the rank of lieutenant in the military police, specializing in communications. He told some journalists that he worked with a military counterintelligence unit, but said he never joined Russian intelligence services — unlike his father, sister and godfather.

In 1992 he graduated with honors from Kazan Federal University, and two years later arrived in Washington as a graduate student in chemistry at the Catholic University of America. He married a fellow Russian chemistry student and received his Ph.D. But he immediately abandoned his esoteric study of mechanistic enzymes and burrowed into Washington’s foreign lobbying scene, promoting clients from Russia and former Soviet states.

He never formally studied English, he said, or owned a car: He pedaled about Washington on a bright orange bicycle. But he was witty and erudite, a lover of literature, opera and snowboarding. Matthew Bryza, a former staff member in charge of Central Asia issues at the National Security Council under President George W. Bush, remembers Akhmetshin as “very smart, slick guy” serving as “the paid drone of unsavory, out-of-fashion former Soviet leaders looking to launder their reputations.”

“He would boast about ties and experience in Soviet intelligence and counterintelligence to give himself some cachet and make himself a mystery man,” he said.

Akhmetshin’s gateway to Washington was Edward Lieberman, a lawyer with corporate and political clients in former Soviet countries who was married to President Bill Clinton’s former deputy chief of staff, Evelyn S. Lieberman, who died in 2015. He called Lieberman, who could not be reached for comment, a personal adviser.

Together the two started the Eurasian Institute for Economic and Political Research. Supposedly set up to promote democratic reforms in former Soviet states, it was essentially a vehicle to burnish the reputation of one client, Akezhan Kazhegeldin, an ex-KGB officer and the former prime minister of Kazakhstan. Kazhegeldin had fled under a cloud of corruption charges and was seeking Washington’s support to challenge his rival, Kazakhstan’s president, Nursultan Nazarbayev.

Akhmetshin worked to undercut his client’s rival by funneling information to U.S. prosecutors pursuing bribery charges against James Giffen, an American businessman close to the Kazakh president, according to people involved with the case. The prosecutors discovered only belatedly that Giffen had worked for the CIA in the former Soviet Union.

By 2005 the government of another former Soviet republic, Kyrgyzstan, had hired Akhmetshin to investigate whether Washington had bribed the family of the country’s former president to keep an American air base there. The Manas base, established as a staging ground for U.S. forces in Afghanistan, was a major source of friction with the Russians.

The Kyrgyz ambassador to Washington at the time, Zamira Sydykova, said Akhmetshin arranged an interview with a Times reporter and escorted her to it. The resulting article helped set off a Washington controversy and ultimately, a congressional investigation. Kyrgyzstan finally forced the U.S. to abandon the base in 2014.

In an affidavit that year, Akhmetshin said he worked closely with the U.S. government about the location of the base. But Thomas Graham, the National Security Council’s Russia specialist from 2002 to 2007, said the controversy put Washington on the defensive. “Looking into allegations of fraud or bribery — anything that would complicate our presence at that air base — was in Russia’s interests,” he said.

Akhmetshin’s work took him back and forth to Europe more than once a month, on trips lasting a few days each. Sen. Charles E. Grassley, R-Iowa, who is now chairman of the Senate Judiciary Committee, has sought to determine whether his travel pattern raised concerns among immigration officials who approved Akhmetshin’s application for U.S. citizenship in 2009.

Once naturalized, Akhmetshin began traveling regularly to Moscow and taking on more overtly pro-Russian projects. The new work led him into legal entanglements, the halls of Congress and eventually Trump Tower.

The hacking campaigns

Few episodes from Akhmetshin’s past seem more relevant to Mueller’s investigation than his work for two Russian billionaires accused of infiltrating their adversaries’ computers during nasty legal battles.

The Trump Tower meeting in June 2016 took place less than a week before revelations that hackers had penetrated the Democratic National Committee’s computers and obtained a trove of emails. Investigators have traced digital espionage to Russian spy agencies. There is no public evidence that Akhmetshin played any role in the DNC hack.

The first hacking case, which has not previously been reported, began when Akhmetshin served an alliance of businessmen led by Suleiman Kerimov — a financier close to Putin in a commercial and political dispute with a Russian competitor, Ashot Egiazaryan.

In early 2011, two London lawyers on Egiazaryan’s team separately received suspicious emails and hired forensic experts to scrutinize them, according to people involved in a Scotland Yard investigation. The experts found that the messages concealed spyware meant to infiltrate their computers, and they fed traceable documents into the spyware that were then opened by computers registered at the Moscow office park of one of Kerimov’s companies.

After an inquiry of more than 18 months, Scotland Yard investigators concluded in January 2013 that they lacked sufficient evidence to bring any charges, a spokesman said. Representatives of the lawyers targeted declined to comment.

Akhmetshin has said in court papers that he was paid only by one businessman in the alliance with Kerimov, but coordinated with Kerimov’s team.

Two years later, hacking accusations arose in another case, this time lodged directly against Akhmetshin. He worked as a consultant to a law firm representing EuroChem, a fertilizer and mining company controlled by another Russian billionaire close to Putin — Andrey Melnichenko. Akhmetshin’s target was a rival mining company, International Mineral Resources.

Within months, documents stored in International Mineral Resources’ computer systems began surfacing outside the company, leaked to journalists and others. The company concluded that its computers had been hacked, and replaced its servers. In lawsuits filed in federal court in Washington and state court in New York, the company accused EuroChem and Akhmetshin of computer espionage.

EuroChem’s information technology chief, Vladimir Chibisov, previously worked in the Russian government. He had written a book promoted as “a hacker’s Bible,” which he described as a book “about us — about Russian programmers, men of the ‘80s and ‘90s” who “had done programming, and even a bit of hacking.”

Akhmetshin personally handed a thumb drive containing stolen documents to a lawyer engaged in another matter potentially damaging to the rival company, according to a person familiar with the matter. The same thumb drive was later obtained by investigators, and someone using the initials “R.A.” had gained access to its contents, according to court papers.

A spokesman for Melnichenko said in a statement that he has never condoned hacking or other illegal activity, nor had he ever met or known Akhmetshin. The spokesman said Chibisov’s book was “tongue in cheek” and “cannot possibly be taken seriously.”

An investigator for the targeted company also testified that he had followed Akhmetshin in January 2014 to a meeting at London’s Cafe Royal and watched him hand over an external hard drive to another individual. He said he had overheard Akhmetshin claim that he had paid a team of Russian hackers “a lot of money” for the records.

Akhmetshin acknowledged in a deposition that he had turned over a hard drive with information about the firm’s owners. But he said he had obtained the data from a Kazakh contact through a loose network he called the London Information Bazaar. Asked about computer hacking, he replied, “I do not know a single person who could do that.”

International Mineral Resources dropped the lawsuits without explanation in early 2016, withdrawing all allegations before they could be adjudicated. The company said in a statement Friday that it dropped the charges “after careful consideration.”

A key Kremlin contact

During the same period that Akhmetshin was accused of being involved in various hacking schemes, he appears to have been nurturing a relationship with Viktor Ivanov, once the deputy head of Russia’s intelligence service, the FSB, and until last year a top aide to Putin.

From 2009 to 2014, Ivanov led the Russian side of a joint effort with the Americans to combat drug trafficking in Afghanistan, part of an early Obama administration initiative to improve relations between Moscow and Washington.

When Ivanov traveled to Washington to promote the effort in October 2010, Akhmetshin helped shepherd him around town. In a deposition filed in one of the hacking cases, Akhkmetshin testified that he helped facilitate the Washington visit with one of Ivanov’s aides, with whom he had served in the Red Army.

In an affidavit in that same case, Akhmetshin said he had been in email contact with Ivanov on matters ranging “from narco-trafficking and terrorism in Afghanistan to surveillance of undercover agents, suspected undercover agents and their identities.”

Reporters who encountered Akhmetshin during his travels to Afghanistan said he grew a beard to blend in with the local population. He never identified whom he worked for, but two former U.S. officials involved with the counternarcotics program said the American side did not hire him.

Ivanov, who retired early last year, could not be reached for comment about whether Akhmetshin was on the Russian government’s payroll.

Russia ended the counternarcotics cooperation in 2014 after the U.S. imposed sanctions on Ivanov and other Putin allies in retaliation for Russia’s invasion and seizure of Ukraine’s Crimea region.

There, too, Akhmetshin had tried to ally with Ukraine’s pro-Moscow elements. Before the 2014 invasion, he told reporters, he unsuccessfully sought consulting work with the political party dominated by the nation’s pro-Putin president, Viktor F. Yanukovych. A popular revolt forced Yanukovych to flee to Russia.

Akhmetshin told journalists that he was a longtime acquaintance of Paul Manafort, who served as a high-paid consultant to Yanukovych for years before becoming chairman of the Trump campaign. Jason Maloni, a spokesman for Manafort, said, “Paul doesn’t know and hasn’t worked with the man.”

Last year, Akhmetshin took on a new project high on the Kremlin’s agenda: a $240,000 lobbying campaign to amend the Magnitsky Act, which imposes sanctions on Russians for human rights abuses. The law was named after Sergei L. Magnitsky, a Russian tax lawyer who died in custody after he uncovered a $230 million tax fraud allegedly tied to Russian officials. Several wealthy Russian businessmen financed a nonprofit group to spearheadthe campaign, which was represented by Akhmetshin and a Russian lawyer named Natalia Veselnitskaya.

Donald Trump Jr. has said the promise of damaging information about Hillary Clinton was just an excuse for Veselnitskaya to get into Trump Tower to talk about why the law should be changed. Akhmetshin, a Washington resident, has told reporters that he just happened to be lunching with Veselnitskaya in Manhattan that day when she spontaneously invited him to the meeting with the president’s son, son-in-law Jared Kushner and Manafort. He did not explain why she wanted him there.

After Akhmetshin’s presence came to light, a spokesman for Putin, Dmitry Peskov, told reporters, “We don’t know anything about this person.”