Illustration by Matthieu Bourel; from top: photographs by the Kremlin, Eric Thayer for The New York Times, Jewel Samad/AFP/Getty Images, Whitten Sabbatini for The New York Times, White House photo

Illustration by Matthieu Bourel; from top: photographs by the Kremlin, Eric Thayer for The New York Times, Jewel Samad/AFP/Getty Images, Whitten Sabbatini for The New York Times, White House photo

Illustration by Matthieu Bourel; from top: photographs by the Kremlin, Eric Thayer for The New York Times, Jewel Samad/AFP/Getty Images, Whitten Sabbatini for The New York Times, White House photo

On an October afternoon before the 2016 election, a huge banner was unfurled from the Manhattan Bridge in New York City: Vladimir V. Putin against a Russian-flag background, and the unlikely word “Peacemaker” below. It was a daredevil happy birthday to the Russian president, who was turning 64.

In November, shortly after Donald J. Trump eked out a victory that Moscow had worked to assist, an even bigger banner appeared, this time on the Arlington Memorial Bridge in Washington: the face of President Barack Obama and “Goodbye Murderer” in big red letters.

Police never identified who had hung the banners, but there were clues. The earliest promoters of the images on Twitter were American-sounding accounts, including @LeroyLovesUSA, later exposed as Russian fakes operated from St. Petersburg to influence American voters.

The Kremlin, it appeared, had reached onto United States soil in New York and Washington. The banners may well have been intended as visual victory laps for the most effective foreign interference in an American election in history.

For many Americans, the Trump-Russia story as it has been voluminously reported over the past two years is a confusing tangle of unfamiliar names and cyberjargon, further obscured by the shout-fest of partisan politics. What Robert S. Mueller III, the special counsel in charge of the investigation, may know or may yet discover is still uncertain. President Trump’s Twitter outbursts that it is all a “hoax” and a “witch hunt,” in the face of a mountain of evidence to the contrary, have taken a toll on public comprehension.

But to travel back to 2016 and trace the major plotlines of the Russian attack is to underscore what we now know with certainty: The Russians carried out a landmark intervention that will be examined for decades to come. Acting on the personal animus of Mr. Putin, public and private instruments of Russian power moved with daring and skill to harness the currents of American politics. Well-connected Russians worked aggressively to recruit or influence people inside the Trump campaign.

To many Americans, the intervention seemed to be a surprise attack, a stealth cyberage Pearl Harbor, carried out by an inexplicably sinister Russia. For Mr. Putin, however, it was long-overdue payback, a justified response to years of “provocations” from the United States.

And there is a plausible case that Mr. Putin succeeded in delivering the presidency to his admirer, Mr. Trump, though it cannot be proved or disproved. In an election with an extraordinarily close margin, the repeated disruption of the Clinton campaign by emails published on WikiLeaks and the anti-Clinton, pro-Trump messages shared with millions of voters by Russia could have made the difference, a possibility Mr. Trump flatly rejects.

A banner of President Vladimir V. Putin of Russia that hung in Manhattan in October 2016. Nathan Tempey A banner of President Barack Obama that appeared the next month in Washington.

As Mr. Trump emerged in spring 2016 as the improbable favorite for the Republican nomination, the Russian operation accelerated on three fronts — the hacking and leaking of Democratic documents; massive fraud on Facebook and Twitter; and outreach to Trump campaign associates.

Consider 10 days in March. On March 15 of that year, Mr. Trump won five primaries, closing in on his party’s nomination, and crowed that he had become “the biggest political story anywhere in the world.” That same day in Moscow, a veteran hacker named Ivan Yermakov, a Russian military intelligence officer working for a secret outfit called Unit 26165, began probing the computer network of the Democratic National Committee. In St. Petersburg, shift workers posted on Facebook and Twitter at a feverish pace, posing as Americans and following instructions to attack Mrs. Clinton.

On March 21 in Washington, Mr. Trump announced his foreign policy team, a group of fringe figures whose advocacy of warmer relations with Russia ran counter to Republican orthodoxy. Meanwhile, Unit 26165 was poring over the bounty from a separate attack it had just carried out: 50,000 emails stolen from the Clinton campaign’s chairman.

On March 24, one of the members of the Trump foreign policy team, George Papadopoulos, sat in the cafe of an upscale London hotel with a Russian woman who introduced herself as Mr. Putin’s niece and offered to help set up a meeting between the Russian president and Mr. Trump. The woman and the adviser exchanged frequent messages in the weeks that followed. Today, Mr. Padadopoulos is unsure that those messages came from the person he met in the cafe.

The Russian intervention was essentially a hijacking — of American companies like Facebook and Twitter; of American citizens’ feelings about immigration and race; of American journalists eager for scoops, however modest; of the naïve, or perhaps not so naïve, ambitions of Mr. Trump’s advisers. The Russian trolls, hackers and agents totaled barely 100, and their task was to steer millions of American voters. They knew it would take a village to sabotage an election.

Russians or suspected Russian agents — including oligarchs, diplomats, former military officers and shadowy intermediaries — had dozens of contacts during the campaign with Mr. Trump’s associates. They reached out through email, Facebook and Twitter. They sought introductions through trusted business connections of Mr. Trump’s, obscure academic institutions, veterans groups and the National Rifle Association.

They met Trump campaign aides in Moscow, London, New York and Louisville, Ky. One claimed the Russians had “dirt” on Hillary Clinton; another Russian, the Trump campaign was told, would deliver it. In May and June alone, the Trump campaign fielded at least four invitations to meet with Russian intermediaries or officials.

In nearly every case, the Trump aides and associates seemed enthusiastic about their exchanges with the Russians. Over months of such probing, it seems that no one alerted the Federal Bureau of Investigation to the foreign overtures.

Mr. Trump’s position on the Russian contacts has evolved over time: first, that there were none; then, that they did not amount to collusion; next, that in any case collusion was not a crime. That is mere semantics — conspiracy is the technical legal term for abetting the Russians in breaking American laws, such as those outlawing computer hacking and banning foreign assistance to a campaign.

Whether Mr. Trump or any of his associates conspired with the Russians is a central question of the investigation by Mr. Mueller, who has already charged 26 Russians and won convictions or guilty pleas from the former national security adviser, Michael T. Flynn; the former campaign chairman, Paul J. Manafort, and his deputy, Rick Gates; and from Mr. Papadopoulos. Mr. Trump’s personal lawyer, Michael D. Cohen, has pleaded guilty in a separate case.

But none of the convictions to date involve conspiracy. There remains an alternative explanation to the collusion theory: that the Trump aides, far from certain their candidate would win, were happy to meet the Russians because they thought it might lead to moneymaking deals after the election. “Black Caviar,” read the subject line of an email Mr. Manafort got in July 2016 from his associate in Kiev, Ukraine, hinting at the possibility of new largess from a Russian oligarch with whom they had done business.

Nina L. Khrushcheva, a professor of international affairs at the New School and the great-granddaughter of the Soviet premier Nikita S. Khrushchev, said that what Russia pulled off, through creativity and sheer luck, would have been the envy of Mr. Putin’s predecessors: puncturing the American sense of superiority and insisting on Russia’s power and place in the world.

“This operation was to show the Americans — that you bastards are just as screwed up as the rest of us,” Professor Khrushcheva said. “Putin fulfilled the dream of every Soviet leader — to stick it to the United States. I think this will be studied by the K.G.B.’s successors for a very long time.”

A Timeline of Parallel Threads Direct contacts with Russians by Trump officials JUNE 16, 2015 Trump announces candidacy Time 2016 Russian social media fraud Russian hacking Denials of wrongdoing by Trump and associates MAY 26, 2016 Trump clinches nomination NOV. 8, 2016 Trump wins election Federal investigation of Russian meddling JAN. 20, 2017 Inauguration JANUARY 2018 SEPTEMBER 2018 Continuing… JUNE 2015 Trump announces candidacy Direct contacts with Russians Time Russian social media fraud 2016 Russian hacking MAY 2016 Trump clinches nomination ELECTION Federal investigation INAUGURATION Denials of wrongdoing by Trump and associates JANUARY 2018 SEPTEMBER 2018 By The New York Times

See the full timeline of events.

Putin Is Angry

The Russian leader thought the United States, and Hillary Clinton, had sought to undermine his presidency.

Illustration by Matthieu Bourel; photograph by the Kremlin

The first Russian advance party was tiny: two women on a whirlwind American tour. Hitting nine states in three weeks in summer 2014, Anna Bogacheva and Aleksandra Krylova were supposed to “gather intelligence” to help them mimic Americans on Facebook and Twitter. They snapped photos and chatted up strangers from California to New York, on a sort of Russian “Thelma & Louise” road trip for the era of social media.

Even then, federal prosecutors would later say, the Russian government was thinking about the next United States presidential election — perhaps ahead of most Americans. Ms. Bogacheva and Ms. Krylova had been dispatched by their employer, an online propaganda factory in St. Petersburg, to prepare to influence American voters.

But why did Mr. Putin care about the election, then more than two years away? He was seething. The United States, in his view, had bullied and interfered with Russia for long enough. It was high time to fight back.

His motives were rooted in Russia’s ambivalence toward the West, captured in the history of St. Petersburg, Russia’s spectacular northern city and Mr. Putin’s hometown. Peter the Great, the brutal but westward-looking 18th-century czar, had brought in the best Italian architects to construct Russia’s “window on Europe” in a swamp.

Czar Peter’s portrait replaced Vladimir Lenin’s in Mr. Putin’s office when he took a job working for the city’s mayor in the early 1990s. Twenty-five years later, the internet offered a different kind of window on the West — a portal that could be used for a virtual invasion.

Mr. Putin, a former K.G.B. officer, had described the breakup of the Soviet Union as the “greatest geopolitical catastrophe” of the 20th century, a remarkable statement from a man whose country experienced revolution, civil war, bloody purges and the deaths of 27 million people in World War II. Like many of his fellow citizens, Mr. Putin was nostalgic for Russia’s lost superpower status. And he resented what he saw as American arrogance.

A Moscow protest against Mr. Putin in 2011. Andrey Rudakov/Bloomberg via Getty Images

The Russian leader believed the United States had relentlessly sought to undermine Russian sovereignty and his own legitimacy. The United States had backed democratic, anti-Russian forces in the so-called color revolutions on Russia’s borders, in Georgia in 2003 and Ukraine in 2004. It had funded pro-democracy Russian activists through American organizations with millions in State Department grants each year.

With little evidence, Mr. Putin believed this American meddling helped produce street demonstrations in Moscow and other cities in 2011, with crowds complaining of a rigged parliamentary election and chanting, “Putin’s a thief!”

Ask a Question Our reporters are available to answer readers' questions on Russia's intervention in the 2016 election, the Mueller investigation and their reporting process. Required fields are marked with an asterisk. What question do you have for our reporters? * Continue What is your name? * First and last preferred, please. What is your email? * Where do you live? May we publish your name and location with your question? * Yes No By clicking the submit button, you agree that you have read, understand and accept the Reader Submission Terms in relation to all of the content and other information you send to us ('Your Content'). If you do not accept these terms, do not submit any content. Of note: Your Content must not be false, defamatory, misleading or hateful or infringe any copyright or any other third party rights or otherwise be unlawful.

We will use the contact details that you provide to verify your identity and answers to the questionnaire, as well as to contact you for further information on this story. If we publish Your Content, we may include your name and location. I have read, understood and accept the Reader Submission Terms Thank you for your submission.

And Mrs. Clinton, then secretary of state, cheered the protesters on. Russians, she said, “deserve the right to have their voices heard and their votes counted, and that means they deserve free, fair, transparent elections and leaders who are accountable to them.”

Mr. Putin blamed Mrs. Clinton for the turmoil, claiming that when she spoke out, his political enemies “heard the signal and with the support of the U.S. State Department began active work.”

The two tangled again the next year when Mr. Putin pushed for a “Eurasian Union” that would in effect compete with the European Union. Mrs. Clinton sharply dismissed the notion, calling it a scheme to “re-Sovietize the region” and saying the United States would try to block it.

By 2013, with his initial hopes for a “reset” of Russian relations dashed, Mr. Obama, like his top diplomat, no longer bothered to be diplomatic. He criticized Russia’s anti-gay legislation, part of Mr. Putin’s effort to become a global champion for conservative values, and gave a biting description of the Russian leader: “He’s got that kind of slouch, looking like the bored kid in the back of the classroom.” Mr. Putin was reported to be furious.

The White House via YouTube

After Russian troops seized Crimea and carried out a stealth invasion of Ukraine in 2014, relations grew openly hostile. American support for the new government in Kiev and condemnation of Russian behavior heightened Mr. Putin’s rage at being told what he could do and not do in what he considered his own backyard.

If Russia had only a fraction of the United States’ military might and nothing like its economic power, it had honed its abilities in hacking and influence operations through attacks in Eastern Europe. And it could turn these weapons on America to even the score.

By making mischief in the 2016 election, Mr. Putin could wreak revenge on his enemy, Mrs. Clinton, the presumed Democratic nominee, damaging if not defeating her. He could highlight the polarized state of American democracy, making it a less appealing model for Russians and their neighbors. And he could send a message that Russia would not meekly submit to a domineering America.

Hence the two Russian women who toured the United States in 2014, keyboard warriors granted the unusual privilege of real-world travel, hitting both coasts, Illinois, Louisiana and Texas. At that point, according to a Russian document cited by the special counsel, Mr. Putin’s intentions for 2016 were already explicit: to “spread distrust toward the candidates and the political system in general.”

In the intervening two years, Mr. Putin’s ire at America only increased. He blamed the United States for pushing for a full investigation of illicit doping by Russian athletes, which would lead to mass suspensions of the country’s Olympic stars. And when the leaked Panama Papers were published in April 2016, revealing that a cellist who was Mr. Putin’s close friend had secret accounts that had handled $2 billion, he charged that it was a smear operation by the United States.

Russian Olympic athletes this year in Pyeongchang, South Korea. Mr. Putin had blamed the United States for pushing to investigate the doping scandal that had engulfed the team. James Hill for The New York Times

“Who is behind these provocations?” he asked. “We know that among them are employees of official American institutions.”

Then something unexpected happened. Of the more than 20 major-party candidates running for the American presidency, only Mr. Trump had repeatedly expressed admiration for Mr. Putin as a “strong” leader and brushed off criticism of Russia. Only he had little interest in the traditional American preoccupation with democracy and human rights. Only he had explored business interests in Russia for years, repeatedly pursuing a Trump Tower project in Moscow and bringing his beauty pageant there in 2013.

“Do you think Putin will be going to The Miss Universe Pageant in November in Moscow,” the future candidate tweeted at the time, adding wistfully, “if so, will he become my new best friend?”

If Mr. Putin had been designing his ideal leader for the United States, he could hardly have done better than Donald Trump.

For some years, Mr. Trump had attracted attention from Russian conservatives with Kremlin ties. A Putin ally named Konstantin Rykov had begun promoting Mr. Trump as a future president in 2012 and created a Russian-language website three years later to support his candidacy. A Russian think tank, Katehon, had begun running analyses pushing Mr. Trump.

Mr. Trump as a candidate was “tough, rough, says what he thinks, rude, emotional and, apparently, candid,” wrote Alexander Dugin, an ultranationalist philosopher considered a major influence on Mr. Putin, in February 2016. Mr. Dugin declared that Mr. Trump probably had “no chance of winning” against the “quite annoying” Mrs. Clinton, but added a postscript: “We want to put trust in Donald Trump. Vote for Trump, and see what will happen.”

Against all expectations, Republicans across the country began to do just that, and soon Mr. Trump was beating the crowd of mainstream Republicans. Mr. Putin, said Yuval Weber, a Russia scholar, “found for the first time since the collapse of the U.S.S.R. that he has a prospective president of the United States who fundamentally views international issues from the Russian point of view.”

Asked about the surging Mr. Trump in December 2015, Mr. Putin said he was “a talent, without any doubt,” and “absolutely the leader in the presidential race.” He also applied to the candidate the Russian word yarkii, which means “colorful” or “flamboyant” but which some reports mistranslated as “brilliant,” an assessment that Mr. Trump immediately began repeating.

“It’s always a great honor to be so nicely complimented,” Mr. Trump said, “by a man so highly respected within his own country and beyond.”

Moscow’s Dream Team

As Donald J. Trump emerged as the favorite for the nomination, his campaign brought on aides tied to Russia.

Illustration by Matthieu Bourel; photograph by the Kremlin

Mr. Trump had steamrollered his primary opponents in part by taking aim at Republican foreign policy orthodoxy. The post-9/11 wars were foolish and costly, he would often say at campaign events. America’s allies were deadbeats and freeloaders, he told supporters, who cheered in agreement. Russia was not an existential threat, he said, but a potential ally in beating back terrorist groups.

In early March 2016, the establishment struck back. In an open letter, dozens of the party’s national security luminaries vowed publicly to try to stop the election of a candidate “so utterly unfitted to the office.”

They took particular umbrage at Mr. Trump’s remarks about the Russian president, writing that his “admiration for foreign dictators such as Vladimir Putin is unacceptable for the leader of the world’s greatest democracy.”

But Mr. Trump was not cowed. He soon signed on new advisers and aides, including some who had been pushed to the fringe of a political party that had long lionized President Ronald Reagan for staring down Soviet leaders at the height of the Cold War.

To the Kremlin, they must have looked like a dream team.

Mr. Flynn, the former head of the Defense Intelligence Agency, had long viewed Russia as a natural ally in what he saw as a “world war” against radical Islam. In June 2013, when he was D.I.A. chief, he sat inside the imposing headquarters of the G.R.U., Russia’s military intelligence agency, and chatted with officers. Two years later, he sat at Mr. Putin’s elbow at a gala dinner in Moscow.

Mr. Putin at a 2015 dinner in Moscow with Michael T. Flynn, seated at his right, and Jill Stein, wearing gray. Pool photo by Mikhail Klimentyev

Mr. Manafort, a longtime Republican lobbyist, had earned millions working for a pro-Kremlin leader in Ukraine and had a history of business dealings with Oleg Deripaska, a Russian aluminum magnate close to Mr. Putin. He was nearly broke when he joined the Trump campaign in March 2016 — hired to help prevent a mass defection of convention delegates — and yet he offered to work on the campaign unpaid.

Carter Page, a businessman who spent several years working in Moscow, was virtually unknown in Washington when Mr. Trump appointed him a foreign policy adviser. But the S.V.R., Russia’s foreign intelligence service, knew who he was.

In 2013, Mr. Page met in New York with a Russian spy posing as an attaché at the United Nations and passed along energy industry documents in hopes of securing lucrative deals in Moscow.

The F.B.I., which had been tracking Russian spies when Mr. Page came on the bureau’s radar, determined that he had no idea he was meeting with a Russian agent.

“I promised him a lot,” said the spy, Victor Podobnyy, speaking to another Russian intelligence officer about his dealings with Mr. Page, according to an F.B.I. transcript. “How else to work with foreigners? You promise a favor for a favor.”

The new team was in place by the end of March, and Mr. Trump had a new message that was strikingly similar to one of Mr. Putin’s most ardent talking points.

“I think NATO’s obsolete,” Mr. Trump said during an interview on ABC’s “This Week.”

“NATO’s not meant for terrorism,” he went on to say. “NATO doesn’t have the right countries in it for terrorism.”

By then, the Russian intelligence operation to intervene in the American election — including efforts to infiltrate and influence the Trump campaign — had begun.

Mr. Papadopoulos, the 28-year-old campaign adviser, did not know this when he met in the cafe of the London hotel with Mr. Putin’s “niece” (he has no niece) and an obscure Maltese professor in late March. The academic had taken an interest in Mr. Papadopoulos when he joined the campaign.

F.B.I. agents have identified the professor, Joseph Mifsud, as a likely cutout for Russian intelligence, sent to establish contact with Mr. Papadopoulos and possibly get information about the direction of the Trump campaign. He disappeared after his name surfaced last October, and his whereabouts is unknown. At one point he changed his WhatsApp status to a simple, if cryptic, message: “Alive.”

Professor Mifsud arranged an email introduction between Mr. Papadopoulos and a Russian foreign ministry official. The American also exchanged emails with Olga Polonskaya, the woman in the cafe. “We are all very excited by the possibility of a good relationship with Mr. Trump,” she wrote in one message, and the two discussed a possible meeting between Mr. Putin and Mr. Trump.

Over time, though, Mr. Papadopoulos came to question whether the messages were actually from Ms. Polonskaya. The woman he had met in the cafe barely spoke English. The emails he received were in nearly perfect English.

“I even remember sending her a message asking if I’m speaking to the same person I met in London because the conversations were so strange,” he said during an interview this month.

In late April, Mr. Trump gave his first major foreign policy address in the ballroom of a historic Washington hotel. Some of the speech was a familiar litany of Republican policy positions — hawkish warnings to Iran and pledges to be tough on terrorism. But midway through the speech, as Russia’s ambassador to the United States watched from the front seats, Mr. Trump pivoted and said the United States and Russia should look for areas of mutual interest.

“Common sense says this cycle, this horrible cycle of hostility, must end, and ideally will end soon,” he said.

The Associated Press

“That’s the signal to meet,” Mr. Papadopoulos wrote in an email to his Russian foreign ministry contact that evening, meaning that Mr. Trump’s favorable comments about Russia suggested he might be interested in meeting Mr. Putin.

Just one day earlier, Professor Mifsud had told the campaign aide about a possible gift from Moscow: thousands of hacked emails that might damage Mrs. Clinton’s candidacy.

It was a breathtaking revelation. But there was no evidence that Mr. Papadopoulos — while ambitious and eager for advancement in the bare-bones campaign — passed the information along to anyone inside the Trump circle.

More than two years later, Mr. Papadopoulos says he has “no recollection” of telling anyone in the campaign about the emails. He said he was supposed to have a phone call that day with Stephen Miller, a top campaign adviser, but it was postponed. If the two men had talked, Mr. Papadopoulos said, he might have shared the information.

“How fate works sometimes, I guess,” said Mr. Papadopoulos, who has been sentenced to 14 days in jail for lying to the F.B.I.

As Mr. Trump continued to win primaries and vacuum up convention delegates late in the spring, the Russians made multiple attempts to establish contact with campaign officials.

A Republican operative connected to the N.R.A. tried to arrange a meeting between Mr. Trump and a Russian central banker at an N.R.A. convention in Kentucky in May. “Putin is deadly serious about building a good relationship with Mr. Trump,” wrote the operative, Paul Erickson, in an email with the subject “Kremlin connection.” “Ever since Hillary compared Putin to Hitler, all senior Russian leaders consider her beyond redemption.”

Mr. Page, the foreign policy adviser, was invited to deliver the commencement address at the prestigious New Economic School in Moscow. That invitation now appears to have been an effort both to gain information about the Trump campaign and to influence it by feting Mr. Page in the Russian capital. Russian television that year was describing him as a “famous American economist,” but he was an obscure figure in this country.

At that time, the last American to give the commencement speech was Mr. Obama, who used the opportunity to criticize Russia for its treatment of Georgia and Ukraine.

Mr. Page, though, criticized the “hypocrisy” of the United States and its NATO allies for lecturing Russia about bullying its neighbors, which were former Soviet republics, while the Westerners were taking “proactive steps to encourage regime change overseas.” During his time in Moscow, Mr. Page met with at least one top Russian official and numerous business leaders.

And there was the now infamous June 2016 approach to Donald Trump Jr. by Russians whom he and his father had known from their days taking the Miss Universe pageant to Moscow. The Russians met at Trump Tower in Manhattan with top campaign officials after promising damaging information on Mrs. Clinton.

See the timeline of events that surround the Trump Tower meeting.

What exactly transpired during the meeting is still a mystery, but it appears that the Russians pulled a bait-and-switch. They used the session to push for an end to the crippling economic sanctions that Mr. Obama had imposed on Russia.

Donald Trump Jr. has said how disappointed he and other campaign advisers were that they didn’t get what the Russians had promised. The campaign’s reaction to the Russian attempts to discredit Mrs. Clinton’s campaign was not to rebuff them or call law enforcement — it was to try to exploit them.

Experts who have studied Russian operations for decades see the catalog of contacts and communications between Russians and Mr. Trump’s advisers as a loosely coordinated effort by Russian intelligence both to get insight into the campaign and to influence it.

“The Russians aren’t reckless, and I don’t see them going through with this effort without thinking they had a willing partner in the dance,” said Rolf Mowatt-Larssen, a former C.I.A. officer who served as the spy agency’s station chief in Moscow.

By midsummer 2016, the Russian contacts sounded alarms inside the F.B.I., where agents had received a tip about Mr. Papadopoulos and puzzled over Mr. Page’s Moscow visit. The bureau sent a trusted informant to help understand what was happening: Stefan Halper, a former Nixon and Reagan adviser and professor at Cambridge University, reached out to Mr. Page and Mr. Papadopoulos under false pretenses.

American officials have defended Professor Halper’s work, saying the use of such a confidential informant is routine in a counterintelligence investigation. Mr. Trump and his allies in Congress and the media have called him something different: a “spy” sent by the Obama administration to infiltrate the campaign.

Eventually, Mr. Trump would use such episodes as a foundation for his view that America’s law enforcement agencies had been aligned against him from the beginning — ammunition for a looming war with the “deep state.” This idea would consume Mr. Trump after he became president, feeding his sense of grievance that the legitimacy of his victory was under attack and shaping his decisions as he tried to blunt the widening Russia investigation.

The long-promised “dirt” the Russians had on Mrs. Clinton would soon be made public. Three days after the Trump Tower meeting, the founder of WikiLeaks, Julian Assange, appeared on a British Sunday television show.

He said that his website would soon be publishing a raft of emails related to Mrs. Clinton. And he said something at once ominous and prescient: “WikiLeaks has a very big year ahead.”

Guccifer’s Game

Using a hacker persona, Russian military intelligence officers began to reveal documents stolen from the Democrats.

Illustration by Matthieu Bourel

A website made its splashy debut three days later, presenting a jaunty hacker who called himself Guccifer 2.0. He had broken into the Democratic National Committee’s computer network, Guccifer said, offering as proof a selection of purloined documents.

“Here are just a few docs from many thousands I extracted when hacking into the DNC’s network,” Guccifer wrote on June 15. “The main part of the papers, thousands of files and mails, I gave to WikiLeaks,” he added — which seemed to explain Mr. Assange’s boast.

Russian intelligence had worked fast. Just the day before, D.N.C. officials and their cybersecurity contractor, CrowdStrike, had announced that Russian hackers had penetrated the committee’s computer network.

Overnight, Russian military intelligence officers set up the website and created the Guccifer persona to counter the D.N.C. accusations. Guccifer — a name borrowed from a real Romanian hacker — was presented as a jovial Romanian, a “lone hacker,” who in his posts wanted to make one thing very clear: He had nothing whatsoever to do with Russia.

“It seems the guys from CrowdStrike and the DNC,” he wrote, “would say I’m a Russian bear even if I were a catholic nun.”

In fact, beyond the conclusions of CrowdStrike and the F.B.I., there were clues from the start that Guccifer’s posts came from Moscow: The name of the founder of the Soviet secret police was embedded in Guccifer’s documents, written using a Russian version of Microsoft Word.

Yet the Guccifer gambit would prove remarkably effective at creating doubt about Russia’s responsibility for the hack. Republican operatives working on congressional campaigns emailed “Guccifer” and received hacked documents relevant to their races. For journalists, the claims of the supposed “lone hacker” made the role of Russian intelligence seem to be a disputed allegation rather than a proven fact.

Today there is no doubt who hacked the D.N.C. and the Clinton campaign. A detailed indictment of 12 officers of Russia’s military intelligence agency, filed in July by Mr. Mueller, documents their every move, including their break-in techniques, their tricks to hide inside the Democrats’ networks and even their Google searches.

See the timeline of hacking that led to the indictment.

The agency, now called the Main Directorate but often referred to by its former abbreviation, the G.R.U., proved agile, brazen and not terribly discreet — the same pattern it would show two years later in the nerve-agent poisoning in England of its former officer, the defector Sergei V. Skripal.

The hacking might have drawn little attention had the G.R.U. stopped there, simply stealing emails to peruse for intelligence clues. But the Russians’ decision to leak the emails to undercut Mrs. Clinton’s candidacy was a huge escalation.

The Russian officers’ political skills proved equal to their hacking expertise. They deftly manipulated a long list of Americans and Europeans, many of whom embraced Guccifer’s tall tale and took seriously the claim that the other Russian false front, DCLeaks.com, was run by American “hacktivists.”

“Guccifer 2.0” addressed a cybersecurity conference in London via messages to one of the organizers. The purported Romanian jousted with a suspicious reporter for Motherboard, insisting: “I don’t like Russians and their foreign policy. I hate being attributed to Russia.” When Twitter suspended the DCLeaks account, the Fox Business host Lou Dobbs accused the company of “Leftist Fascism.” The account was swiftly reinstated.

But the Russians’ masterstroke was to enlist, via the Guccifer persona, the help of WikiLeaks. Neither of the Russians’ websites, Guccifer 2.0 or DCLeaks.com, had much reach. But WikiLeaks had a large global audience. Its editor, Mr. Assange, shared Mr. Putin’s hatred of Mrs. Clinton and had a soft spot for Russia.

Mr. Assange assisted with the subterfuge. He repeatedly denied that he’d received the documents from Russia; whether he was really taken in by the “Guccifer” ruse is uncertain.

Fox News via YouTube

But he also obscured the Russian role by fueling a right-wing conspiracy theory he knew to be false. He offered a $20,000 reward for information about the murder in Washington of Seth Rich, a young D.N.C. staffer shot to death in an apparent bungled street robbery. Trump supporters were suggesting Mr. Rich had leaked the D.N.C. emails and been killed in retaliation, and Mr. Assange played along.

In a discussion about WikiLeaks’ sources on Dutch television in August 2016, Mr. Assange suddenly brought up Mr. Rich’s killing.

“That was just a robbery, I believe, wasn’t it?” the interviewer said. “What are you suggesting?”

“I’m suggesting that our sources take risks,” Mr. Assange said — and then declined to say if Mr. Rich was a source.

Such misleading interviews helped camouflage the Russian origin of the leak, and WikiLeaks’ adept timing gave the emails big impact. After some technical problems, according to Mr. Mueller’s indictment, “Guccifer” passed the entire archive of D.N.C. emails to WikiLeaks. The website published 19,252 of them on July 22, 2016 — three days before the Democratic National Convention.

The Russians’ work detonated with powerful political effect. The emails’ exposure of D.N.C. staffers’ support for Mrs. Clinton and scorn for Senator Bernie Sanders, her chief rival, forced the committee’s chairwoman, Representative Debbie Wasserman Schultz, to resign. The resentment of the Sanders delegates deepened, leaving the party even more bitterly divided as it turned to the general election.

Unknown to the feuding Democratic delegates, a cyberdrama had been playing out in secret for weeks, as CrowdStrike experts tried to root out the Russian hackers who had penetrated the D.N.C. and its sister organization, the Democratic Congressional Campaign Committee.

Robert S. Johnston, a lead investigator for CrowdStrike, said the Russian hackers, uniformed officers of military intelligence, were “like a thunderstorm moving through the system — very, very noisy.”

CrowdStrike had begun watching the Russians in April, asking D.N.C. staffers to keep quiet about the intrusion. “We only talked over Signal,” an encrypted text and call service, said Mr. Johnston, a former Marine and veteran of the United States Cyber Command who is now chief executive of the cybersecurity firm Adlumin. Only by following the hackers for several weeks could CrowdStrike be certain it had found the Russians’ tools and blocked their access.

But somehow, possibly by intercepting communications inside the D.N.C. or the F.B.I., which was investigating the breach, the G.R.U. officers learned they had been spotted. On May 31, two weeks before the public disclosure of the hack, Ivan Yermakov, a G.R.U. hacker who had used American-sounding online personas — “Kate S. Milton,” “James McMorgans” and “Karen W. Millen” — suddenly began searching online for information about CrowdStrike. He sought to find out what the cybersleuths knew about the Russians’ main tool, a nasty piece of malware called X-Agent, the indictment noted.

After that, the spy-versus-spy contest escalated. “We knew it was the Russians, and they knew we knew,” Mr. Johnston said. “I would say it was the cyber equivalent of hand-to-hand combat.”

The candidate favored by the Russians alternated between denying their help and seeming to welcome it. On June 15, the day after the D.N.C. hack was disclosed, the Trump campaign pitched in with a novel idea to deflect blame from the Russians: The D.N.C. had somehow hacked itself.

“We believe it was the D.N.C. that did the ‘hacking’ as a way to distract from the many issues facing their deeply flawed candidate,” the statement said. Later, Mr. Trump tried out other alternative theories: Perhaps the hack had been carried out by “somebody sitting on their bed that weighs 400 pounds,” or a “some guy in his home in New Jersey,” or the Chinese, or almost anyone.

But at other times, he appeared to accept that Russia was responsible.

“The new joke in town,” Mr. Trump tweeted on July 25, “is that Russia leaked the disastrous DNC emails, which should have never been written (stupid), because Putin likes me.”

And two days later, he famously invited the Russians to try to retrieve 30,000 emails that Mrs. Clinton had deleted from her computer server on the basis that they involved personal matters and not State Department business.

“Russia, if you’re listening, I hope you’re able to find the 30,000 emails that are missing,” Mr. Trump said during a Florida news conference. The Mueller investigation discovered that the Russians were evidently listening: The same day as the news conference, the G.R.U. hackers began sending so-called spearphishing emails to accounts associated with Mrs. Clinton’s personal office.

The Associated Press

Mr. Trump’s pronouncements stood in striking contrast to the responses of past presidential candidates who had been offered assistance by foreign powers. In 1960, both Adlai E. Stevenson and John F. Kennedy refused quiet offers of help from Khrushchev.

“Because we know the ideas of Mr. Stevenson, we in our hearts all favor him,” Khrushchev said in a message passed on by the Soviet ambassador. “Could the Soviet press assist Mr. Stevenson’s personal success? How?”

Mr. Stevenson declined the offer, in language that reflected the broad American political consensus about foreign election interference. “I believe I made it clear to him,” Mr. Stevenson wrote, “that I considered the offer of such assistance highly improper, indiscreet and dangerous to all concerned.”

Russia did not deliver on Mr. Trump’s request for Mrs. Clinton’s deleted emails. But it had obtained something just as useful: 50,000 emails of John Podesta, Mrs. Clinton’s campaign chairman, stolen via a phishing attack by the G.R.U. Roger Stone, a political operative and longtime Trump friend, seemed to have advance word. “Trust me,” he wrote on Twitter on Aug. 25, it would soon be “Podesta’s time in the barrel.”

But WikiLeaks withheld the Podesta emails for months after receiving them from “Guccifer” in June, evidently waiting for the right moment to have the biggest impact on the race. The time came on Oct. 7, amid two blows to the Trump campaign.

See the timeline of events that surround the release of the emails.

That day, American intelligence agencies made their first official statement that the Russian government, with the approval of its “senior-most officials,” was behind the hacking and leaking of the Democratic emails.

And then came a potentially lethal disclosure for the Trump campaign: the shocking “Access Hollywood” recording in which Mr. Trump bragged of groping and sexually assaulting women. The candidate desperately needed to change the subject — and that was the moment WikiLeaks posted the first of thousands of Mr. Podesta’s emails.

They were invaluable for political journalists, offering embarrassing comments from staffers about Mrs. Clinton’s shortcomings and the full texts of her highly paid speeches to banks and corporations, which she had refused to release. WikiLeaks assisted by highlighting interesting tidbits in yellow.

Soon, Mr. Trump was delighting his supporters by reading from the stolen emails on the campaign trail. “Now, this just came out,” he told a fired-up crowd in Wilkes-Barre, Pa., in October, brandishing a page of highlights. “WikiLeaks! I love WikiLeaks!”

“Crooked Hillary” had said “behind closed doors,” Mr. Trump declared, that terrorism was “not a threat”; that she had “a great relationship with the financial industry”; that ISIS might infiltrate groups of refugees coming to the United States; that a politician needed to have “both a public and private position” on policies; and on and on.

The quotes were taken out of context, of course, and subjected to the most damaging interpretation. But they seemed to offer a glimpse of Mrs. Clinton’s hidden views.

For the last month of the campaign, in daily releases that kept the Clinton team on the defensive, WikiLeaks delivered the Russians’ gift. If the July D.N.C. dump had been an explosion, the October series was more like unrelenting sniper fire. Whether the timing was decided by the Russians or by Mr. Assange, it proved devastatingly effective.

Imaginary Americans

Russian trolls, using fake accounts on social media, reached nearly as many Americans as would vote in the election.

Illustration by Matthieu Bourel

David Michael Smith, a Houston political scientist and activist, spotted the alarming call on Facebook. A group called Heart of Texas was suddenly urging Texans to come at noon on May 21, 2016, to protest a 14-year-old Islamic center in downtown Houston.

“Stop Islamization of Texas,” the post declared, with a photo of the Islamic Da’wah Center, which it called a “shrine of hatred.” It invited protesters to prepare for battle: “Feel free to bring along your firearms, concealed or not!”

“We immediately asked, ‘What the blank is the Heart of Texas’?’” recalled Mr. Smith, who started calling friends to organize a counterprotest.

Months later, he would find out.

Heart of Texas, which garnered a quarter-million followers on Facebook, was one of 470 Facebook pages created 5,000 miles from Houston at the Internet Research Agency, the oddly named St. Petersburg company that would become the world’s most famous manipulator of social media. The two Russian employees who had visited Texas during that 2014 American tour, Ms. Bogacheva and Ms. Krylova, evidently had returned home with big ideas about how to exploit the emotional chasms in American politics and culture.

Just as the Russians’ Guccifer character had reached out to American activists, journalists and WikiLeaks, the Russian online trolls understood that their real political power would come from mobilizing Americans. The Russian company’s formula was simple: tap into a simmering strain of opinion in the United States and pour on the fuel.

Consider the Texas protest. After the Russians put up the “Stop Islamization” Facebook post, several dozen like-minded Texans added their own incendiary comments. “Allah Sucks,” wrote one, adding a threat to kill any Muslim who tried to visit him. Another wrote of the Islamic center, “Need to Blow this place up.”

A dozen yelling white supremacists turned out for the protest, at least two of them with assault rifles and a third with a pistol. Others held Confederate flags and a “White Lives Matter” banner.

Houston police managed to keep them away from a much larger crowd of counterprotesters — some of whom had responded to a second Russian Facebook call. In a blatant attempt to create a confrontation, another Internet Research Agency page, this one called United Muslims of America, had asked people to rally at exactly the same time and place to “Save Islamic Knowledge.”

Russian online trolls organized a protest of an Islamic center in Houston in 2016. Jon Shapley/Houston Chronicle

The event had no lasting consequences, though clearly it could have ended in tragedy. Still, it demonstrated that young Russians tapping on keyboards in 12-hour shifts could act as puppet masters for unsuspecting Americans many time zones away.

When Facebook first acknowledged last year the Russian intrusion on its platform, it seemed modest in scale. The $100,000 spent on ads was a trivial sum compared with the tens of millions spent on Facebook by both the Trump and Clinton campaigns.

See the timeline of events that shows Russia’s social media campaign.

But it quickly became clear that the Russians had used a different model for their influence campaign: posting inflammatory messages and relying on free, viral spread. Even by the vertiginous standards of social media, the reach of their effort was impressive: 2,700 fake Facebook accounts, 80,000 posts, many of them elaborate images with catchy slogans, and an eventual audience of 126 million Americans on Facebook alone. That was not far short of the 137 million people who would vote in the 2016 presidential election.

Tweets from Russian Trolls, by Day Oct. 6 18,634 tweets Tweets spike on Oct. 6, the day before the Obama administration formally accuses the Russian government of hacking. Bars show the number of tweets per day from Russian troll accounts associated with the Internet Research Agency. Election Day 5,000 tweets Feb. 2016 March April May June July Aug. Sept. Oct. Nov. Source: Darren Linvill and Patrick Warren, Clemson University Oct. 6 18,634 tweets Election Day Bars show the number of tweets per day from Russian troll accounts associated with the Internet Research Agency. Tweets spike on Oct. 6, the day before the Obama administration formally accuses the Russian government of hacking. 5,000 tweets Feb. 2016 March April May June July Aug. Sept. Oct. Nov. Source: Darren Linvill and Patrick Warren, Clemson University Feb. 2016 Bars show the number of tweets per day from Russian troll accounts associated with the Internet Research Agency. March April May Tweets spike on Oct. 6, the day before the Obama administration formally accuses the Russian government of hacking. June July Aug. Sept. Oct. 6 18,634 tweets Oct. Election Day Nov. Source: Darren Linvill and Patrick Warren, Clemson University By The New York Times

And Facebook was only the biggest of the engines powering the Russian messages.

On Instagram, there were 170 ersatz Russian accounts that posted 120,000 times and reached about 20 million people. Twitter reported that in the 10 weeks before the election some 3,814 Internet Research Agency accounts interacted with 1.4 million people — and that another 50,258 automated “bot” accounts that the company judged to be Russia-linked tweeted about the election. The trolls created at least two podcasts, posted Vine videos, blogged on Tumblr, sought donations via PayPal and even exploited the Pokémon Go craze.

Without American social media companies, the Russian influence campaign could not have operated. The St. Petersburg trolls tapped the power of Silicon Valley for their stealth intervention in American democracy.

Darren Linvill, a professor at Clemson University who has studied three million Internet Research Agency tweets, said he was “impressed with both their level of absurdist creativity and keen understanding of American psychology.” They knew “exactly what buttons to press” and operated with “industrial efficiency,” he said.

The Russian troll operation had gotten its start two years before, focusing at first on government targets closer to home.

In 2014, Vitaly Bespalov, then 23, finished a journalism degree in the Siberian city of Tyumen and signed on as a “content manager” at the Internet Research Agency, which looked vaguely like a digital marketing firm and offered a relatively generous salary of $1,000 a month.

Mr. Bespalov was surprised to discover that his job was to write or swipe stories to post on counterfeit Ukrainian websites, spinning the conflict there to fit the Russian government’s view. He had to be sure always to use the word “terrorists” for the Ukrainian fighters opposed to the Russian invasion that was tearing the country apart.

“My first days on the job I was in shock — I had no idea what kind of an operation this was,” Mr. Bespalov said in a recent interview while vacationing in Ukraine: his first visit to the country about which he had written so many bogus stories.

He was put off by the company’s work but said he chose to stick around for several months, in part to study its operations. “It was very monotonous and boring,” Mr. Bespalov said. “It seemed that almost no one liked this work. But almost nobody quit, because everyone needed the money.”

Soon he began hearing about a new, secretive department inside the St. Petersburg company that was recruiting English speakers to focus on the United States.

Like Peter the Great, the Internet Research Agency borrowed Western technology while shunning Western notions of democracy. As Mr. Bespalov quickly realized, the company was not a normal business but a well-compensated tool of the Russian state. It was owned by Yevgeny V. Prigozhin, who overcame an early prison sentence for robbery to create a thriving catering business. He then built a fortune as a loyal contractor willing to provide internet trolls, mercenary soldiers or anything else required by his patron, Mr. Putin.

In the company’s new department, some 80 young English speakers worked in shifts to feed Facebook pages and Twitter accounts imitating the snark and fury of outraged Americans. They stole photos, favoring attractive young women, for their Twitter profiles. They copied or created sharp poster-like commentaries on American life and politics, only occasionally slipping up with grammatical mistakes. They focused their efforts on pages that touched American nerves, with names like “Guns4Life,” “Pray for Police,” “Stop All Invaders,” “South United” and — mimicking Mr. Trump — “America First.”

A post on a page made by Russian trolls.

If Mr. Trump was borrowing the hacked emails from the Russians for his stump speeches, the online trolls in St. Petersburg returned the favor, picking up the candidate’s populist rhetoric. Even pages that seemed nominally hostile to him often worked in his favor: “Woke Blacks” critiqued Mrs. Clinton for alleged hostility to African-Americans; “United Muslims of America” showed her with a woman in a head scarf and a slogan — “Support Hillary, Save American Muslims” — that seemed aimed at generating a backlash.

The Russians managed to call a dozen or more rallies like the one in Houston, sometimes paying unwitting American activists for their help via money transfer. The same method may have been used to get the bridge banners of Mr. Putin and Mr. Obama hung.

An Internet Research Agency Twitter account, @cassishere, posted a photo of the Putin banner on the Manhattan Bridge, winning a credit from The New York Daily News. In Washington, the Russian account @LeroyLovesUSA tweeted about suspending the Obama banner, then added more tweets with critiques of Mr. Obama’s foreign policy in stilted English.

Facebook, reluctant to step into the divisive politics of the Trump presidency, did not acknowledge the Russian intrusion until nearly a year after the election, asserting that Russia had chiefly aimed at sowing division. A closer look suggested a more focused goal: damaging Mrs. Clinton and promoting Mr. Trump.

Many of the Facebook memes portrayed Mrs. Clinton as angry, corrupt or crazed. Mr. Trump was depicted as his campaign preferred: strong, decisive, courageous, willing to shun political correctness to tell hard truths. The Russian operation also boosted Jill Stein, the Green Party candidate who had dined with Mr. Putin in Moscow, to draw votes from Mrs. Clinton. It encouraged supporters of Mr. Sanders to withhold their votes from Mrs. Clinton even after he endorsed her.

The impact is impossible to gauge; the Internet Research Agency was a Kremlin fire hose of influence wielded amid a hurricane of a presidential election. Christopher Painter, who had served under President George W. Bush at the Justice Department and as the State Department’s coordinator for cyberissues from 2011 to 2017, said the propaganda flood and the leaked emails certainly affected the vote. But no one can say whether it made the difference in an election decided by the tiniest of margins, fewer than 100,000 votes in three states.

“It’s impossible to know how much voter suppression it caused, discouraging people from coming out,” Mr. Painter said. “It’s impossible to know how many votes it changed.”

He added that “people don’t like to admit they’ve been fooled” — hence the strenuous efforts from Mr. Trump and his supporters to deny or dismiss the significance of the Russian interference.

A case in point would be Harry Miller, a devoted Trump supporter in Florida who was paid to organize a rally in which a woman portraying Mrs. Clinton sat behind bars on the back of his pickup truck. It turned out that the people who had ordered up the rally, “Matt Skiber” and “Joshua Milton,” were pseudonyms for Russians at the Internet Research Agency, according to the Mueller indictment.

But don’t tell that to Mr. Miller. Contacted via Twitter, he insisted that he had not been manipulated by Russian trolls.

“They were not Russians, and you know it,” Mr. Miller wrote, adding, “If you don’t then you are the one snookered.”

‘It’s a Hoax, O.K.?’

The president has created doubts about the investigation and an affinity for Russia among his supporters.

Illustration by Matthieu Bourel; clockwise from top left: photographs by Reuters, Associated Press, Corbis via Getty Images, Associated Press

The White House statement released at 7:21 p.m. on May 17, 2017, was measured, even anodyne. Reacting to the news that Mr. Mueller had been appointed special counsel for the Russia investigation, the statement quoted Mr. Trump saying that he was “looking forward to this matter concluding quickly,” and that in the meantime he would be fighting “for the people and issues that matter most to the future of our country.”

Exactly 12 hours and 31 minutes later, early in the morning without his staff around him, he told the world what he really thought.

“This is the single greatest witch hunt of a politician in American history!” he wrote in a tweet.

It had been little more than a week since the president had fired his F.B.I. director, James B. Comey, but the “Russia thing” wasn’t going away. Now the president was up against someone who could become even more formidable — a careful, tenacious former Marine whose stewardship of the F.B.I. during the Bush and Obama years had been praised by Washington’s establishment.

Mr. Trump’s instinct was to fire Mr. Mueller, but he settled for a different strategy. He has used all his power to try to discredit the special counsel’s investigation.

Revelation upon revelation about Russian encounters with Trump associates has followed in the months since Mr. Mueller was appointed, intensifying the fear in the White House. Mr. Trump has used his Twitter pulpit to repeatedly assault the Mueller inquiry, and has made scathing remarks at rallies about claims of Russian interference. “It’s a hoax, O.K.?” he told a Pennsylvania crowd last month. The attacks have had an impact on how Americans view the country’s national security apparatus, how they view the Russia story, even how they view Russia itself.

See the full timeline of Mr. Trump’s repeated denials and attacks.

The strategy has helped sow doubts about the special counsel’s work in part because Mr. Mueller and his prosecutors only rarely go public with the evidence they have been steadily gathering in secret interviews and closed-door sessions of a grand jury.

During a period of 146 days over this year — between the Feb. 16 indictment of the Internet Research Agency operatives and the July 13 indictment of Russian intelligence officers — Mr. Mueller’s office was effectively silent. The president was not, sending at least 94 tweets that denied he had been involved in “collusion,” called the Russian interference a “hoax” or labeled the Mueller investigation a “witch hunt.”

Indictment of Internet Research Agency operatives Indictment of Russian intelligence officers Each box represents one Trump tweet calling the Russia investigation a “hoax,” or a “witch hunt,” or disputes any notion of “collusion.” April July Oct. April July Jan. 2017 Jan. 2018 Each box represents one Trump tweet calling the investigation a “hoax,” or a “witch hunt,” or disputes any notion of “collusion.” Jan. 2017 April July Oct. Jan. 2018 Indictment of Internet Research Agency operatives April Indictment of Russian intelligence officers July Each box represents one Trump tweet calling the investigation a “hoax,” or a “witch hunt,” or disputes any notion of “collusion.” Indictment of Internet Research Agency operatives Indictment of Russian intelligence officers Jan. 2017 April July Oct. Jan. 2018 April July Each box represents one Trump tweet calling the Russia investigation a “hoax,” or a “witch hunt,” or disputes any notion of “collusion.” Jan. 2017 April July Oct. Jan. 2018 Indictment of Internet Research Agency operatives April Indictment of Russian intelligence officers July

By July, one poll showed that 45 percent of Americans disapproved of how Mr. Mueller was handling the investigation, a 14-point increase from January. The shift was even more dramatic among Republican voters: from 49 percent to 78 percent. More recent polls, conducted since the indictment of the G.R.U. officers and Mr. Manafort’s conviction, have shown a reversal of the trend.

The president’s aides hardly make a secret of their goal to discredit the investigation before a jury of the public. There is little expectation that Mr. Mueller would ignore Justice Department guidelines and try to indict a sitting president, so Mr. Trump’s lawyers see Congress and impeachment as the only threat. Turn the public against impeachment, the thinking goes, and Congress is less likely to act.

“Mueller is now slightly more distrusted than trusted, and Trump is a little ahead of the game,” Rudolph W. Giuliani, the president’s omnipresent lawyer, told The New York Times last month, without citing any data to buttress his assertion.

“So I think we’ve done really well,” he said. “And my client’s happy.”

Mr. Trump’s frustration with the Russian investigation is not surprising. He is right that no public evidence has emerged showing that his campaign conspired with Russia in the election interference or accepted Russian money. But the inquiry has buffeted his presidency, provoked concern that his attempts to thwart the investigation amount to obstruction of justice and fed his suspicion that the F.B.I. and intelligence agencies — what he calls “the deep state” — are conspiring against him.

The Associated Press

The desire of the president to make deals with Mr. Putin, and the longstanding skepticism of the intelligence community about Russian intentions and actions, might have made a clash inevitable. But Mr. Trump appears to have had success in persuading some Americans that the spy and law enforcement agencies are corrupt and hyperpartisan. He has scrambled alliances that solidified over decades, including the Republican Party’s reflexive support of the national security agencies. A president in open war with the F.B.I., once inconceivable, is now part of the daily news cycle.

Mr. Trump began laying the foundation immediately after he won the presidency, when he questioned the intelligence agencies’ findings that Russia had disrupted the election, and likened America’s spies to Nazis. Since taking office, he has worked with partners in Congress to cast the agencies as part of an insurgency against the White House.

It continued in July, when he stood next to Mr. Putin in Helsinki, Finland, and declared that he trusted the Russian president’s assurances that Moscow was innocent of interfering in the 2016 election.

And it continues today. Early one morning last week, hours before flying to Pennsylvania to honor the victims of the flight that crashed on Sept. 11, 2001, the president fired off a tweet that appeared to quote something he had seen on Fox News.

“‘We have found nothing to show collusion between President Trump & Russia, absolutely zero, but every day we get more documentation showing collusion between the FBI & DOJ, the Hillary campaign, foreign spies & Russians, incredible.’”

The reshuffling of alliances has seeped into the media, where the president’s reliable allies have been joined by voices on the left to dismiss the Russia story as overblown. They warn of a new Red Scare.

On Fox News, the network where Sean Hannity fulminates nightly about Mr. Mueller and his team, the journalist Glenn Greenwald, a founder of the left-leaning news site The Intercept and a champion of government whistle-blowers, has appeared regularly to dismiss revelations about the investigation and decry officials “willing to leak, even at the expense of committing crimes,” in order to damage Mr. Trump.

Multiple frenzied television segments and hyped news stories have given credence to the concerns of Mr. Greenwald and others about a 21st-century McCarthyism. And critics of the “deep state” were given powerful ammunition after the release of text messages between two F.B.I. officials involved in the Russia investigation, Peter Strzok and Lisa Page, that revealed their animosity toward Mr. Trump. The pair, who were involved in a romantic relationship at the time, have been skewered regularly on Mr. Hannity’s show as the “Trump-hating F.B.I. lovebirds.”

Meanwhile, Mr. Trump’s glowing words about Mr. Putin and Russia have created a new affinity for Russia — in particular its social conservatism and toughness on terrorism — among Mr. Trump’s most devoted supporters.

During a period of myriad accounts about Russia’s attempts to disrupt the last election, the percentage of Republicans who view Mr. Putin favorably has more than doubled (from 11 percent to 25 percent), according to a poll by the Pew Research Center. Democrats are now far more likely than Republicans to see Russia as a threat. An October 2017 poll showed that 63 percent of Democrats and just 38 percent of Republicans said they saw “Russia’s power and influence” as a significant threat to the United States.

Once again, Mr. Trump has flipped the script in the party of Reagan: A country that was once seen as a geopolitical foe is now embraced by many Republicans as a bastion of Christianity and traditional values.

Michael McFaul, ambassador to Russia during the Obama administration, said that despite the country’s relative economic and military weakness, Mr. Putin had often played a poor hand deftly. “Across many dimensions, Putin is using all kinds of instruments of power,” he said.

“It feels to me,” the former ambassador said, “like he’s winning and we’re losing.”

On July 16, the president woke early in Helsinki, hours before he was to sit face to face with Mr. Putin. The meeting came three days after Mr. Mueller indicted the 12 Russian intelligence officers. Once again, Mr. Trump dashed off a tweet.

President Trump meeting with Mr. Putin in Helsinki, Finland, in July. Doug Mills/The New York Times

“Our relationship with Russia has NEVER been worse thanks to many years of U.S. foolishness and stupidity and now, the Rigged Witch Hunt!” he wrote.

Russia’s foreign ministry responded with a simple tweet hours later.

“We agree.”