WASHINGTON — The Justice Department charged 13 Russians and three companies on Friday in a sprawling indictment that unveiled a sophisticated network designed to subvert the 2016 election and to support the Trump campaign. It stretched from an office in St. Petersburg, Russia, into the social feeds of Americans and ultimately reached the streets of election battleground states.

The Russians stole the identities of American citizens, posed as political activists and used the flash points of immigration, religion and race to manipulate a campaign in which those issues were already particularly divisive, prosecutors said.

Some of the Russians were also in contact with “unwitting individuals associated with the Trump campaign,” according to court papers. Robert S. Mueller III, the special counsel leading the investigation, made no accusation that President Trump or his associates were knowingly part of the conspiracy.

“The indictment alleges that the Russian conspirators want to promote discord in the United States and undermine public confidence in democracy,” Rod J. Rosenstein, the deputy attorney general overseeing the inquiry, said in a brief news conference. “We must not allow them to succeed.”

The 37-page indictment — handed up by a federal grand jury in Washington — amounted to a detailed rebuttal of Mr. Trump, who has sowed doubts that Russia interfered in the election and dismissed questions about its meddling as “fake news.”

The Justice Department said Mr. Mueller’s work was not complete. The indictment does not address the hacking of Democratic email systems or whether Mr. Trump tried to obstruct the F.B.I. investigation into Russian interference. Mr. Mueller is negotiating with the president’s lawyers over the terms of a possible interview.

The Russian operation began four years ago, well before Mr. Trump entered the presidential race, a fact that he quickly seized on in his defense. “Russia started their anti-US campaign in 2014, long before I announced that I would run for President,” he wrote on Twitter. “The results of the election were not impacted. The Trump campaign did nothing wrong - no collusion!”

But Mr. Trump’s statement ignored the government’s conclusion that, by 2016, the Russians were “supporting the presidential campaign of then-candidate Donald J. Trump” and disparaging Hillary Clinton, his opponent. Working out of the office in St. Petersburg, the Russians described waging “information warfare against the United States of America,” according to court documents.

Mr. Mueller has gathered extensive evidence of contacts between Russia and the Trump campaign: Mr. Trump’s eldest son met with a Russian lawyer in hopes of receiving political dirt on Mrs. Clinton; one adviser has admitted being tipped off in advance to Russian hacking of Democratic emails; another was in contact with a Twitter account used by Russian hackers; a federal judge found probable cause that a third adviser was an unlawful Russian agent. And the Trump campaign repeatedly and falsely denied any contacts with Russia.

Whether any of that violated federal law is the weightiest question facing Mr. Mueller, and Friday’s indictment did not answer it. But it painted a picture of a Russian operation that was multipronged, well financed and relentless.

Russian operatives traveled across the United States to gather intelligence and foment political discord. They worked with an unidentified American who advised them to focus their efforts on what they viewed as “purple” election battleground states, including Colorado, Virginia and Florida, the indictment said.

In August 2016, prosecutors said, Russians posed as Americans and coordinated with Trump campaign staff to organize rallies in Florida.

Such anecdotes are rare examples of how intelligence agencies work covertly to influence political outcomes abroad. The C.I.A. has conducted such operations for decades, but both Mr. Mueller’s indictment and an intelligence assessment last year present a startling example — unprecedented in its scope and audacity — of a foreign government working to help elect an American president.

The indictment does not explicitly say the Russian government sponsored the effort, but American intelligence officials have publicly said that President Vladimir V. Putin of Russia directed and oversaw it. The indictment notes that two of the Russian firms involved hold Russian government contracts.

“This is clearly a message document,” Robert S. Litt, the former general counsel to the director of national intelligence, said of the indictment. “Mueller wants to end the debate over whether there was Russian interference in the election.”

The Russian nationals were accused of working with the Internet Research Agency, which had a budget of millions of dollars and was designed to reach millions of Americans. The defendants were charged with carrying out a massive fraud against the American government and conspiring to obstruct enforcement of federal laws.

None of the defendants were arrested — Russia does not generally extradite its citizens to the United States. But prosecutors use such indictments to name and shame operatives, making it harder for them to work undetected in the future. If they travel abroad, they risk capture and extradition.

Russian computer specialists, divided into day teams and night teams, created hundreds of social media accounts that eventually attracted hundreds of thousands of online followers. They posed as Christian activists, anti-immigration groups and supporters of the Black Lives Matter movement. One account posed as the Tennessee Republican Party and generated hundreds of thousands of followers, prosecutors said.

Separate divisions of the Internet Research Agency were in charge of graphics, data analysis and information technology, according to the indictment.

“I created all these pictures and posts, and the Americans believed that it was written by their people,” one of the Russians, Irina Viktorovna Kaverzina, wrote as the operation was being unmasked.

Their tasks included undermining Mrs. Clinton by supporting her Democratic primary campaign rival, Bernie Sanders, prosecutors said. Those instructions were detailed in internal documents: “Use any opportunity to criticize Hillary and the rest (except Sanders and Trump — we support them).” Mr. Mueller identified 13 digital advertisements paid for by the Russian operation. All of them attacked Mrs. Clinton or promoted Mr. Trump.

Video

How do bots and trolls work to infiltrate social media platforms and influence U.S. elections? We take a closer look at these insidious online pests to explain how they work.

“Hillary is a Satan, and her crimes and lies had proved just how evil she is,” one advertisement stated.

In summer 2016, as Mrs. Clinton appeared headed for a decisive general election victory, Russian operatives promoted allegations of Democratic voter fraud. That echoed Mr. Trump’s own message that he was the victim of a rigged political system.

After the election, the Russians kept up their efforts to foment dissent. In November, they staged two rallies in New York on the same day. One had the theme, “Show your support for President-Elect Trump.” The other was called, “Trump is NOT my President.”

The indictment does not say that Russia changed the outcome of the election, a fact that Mr. Rosenstein noted repeatedly. American intelligence officials have said they have no way of calculating the effect of the Russian influence.

The Federal Election Commission started its own inquiry into the Internet Research Agency last year, according to documents obtained by The New York Times, after Facebook revealed that the firm had paid more than $100,000 for politically themed ads, including ones promoting “Down With Hillary” rallies.

The commission’s inquiry was prompted by a complaint filed by the government watchdog group Common Cause that claimed that the Facebook ads violated the prohibition on foreign spending, as well as requirements mandating the disclosure of campaign spending.

The Kremlin’s spokesman, Dmitri S. Peskov, told the RBC news website that Russian officials have not familiarized themselves with the document yet.

Mr. Mueller also revealed Friday that Richard Pinedo, of Santa Paula, Calif., had pleaded guilty to identity fraud in a case involving the sale of bank accounts over the internet. According to court papers, some of Mr. Pinedo’s customers are foreigners who are targets of Mr. Mueller’s inquiry. Mr. Pinedo has pleaded guilty and is cooperating with Mr. Mueller, court documents show.

Scott Shane and Kenneth P. Vogel contributed reporting from Washington, Michael Schwirtz from New York, and Ivan Nechepurenko from Moscow.