(Reuters/Eric Thayer/Files)

The legal battle between Twitter and the U.S. government ended Friday as the Department of Homeland Security withdrew its demand that the tech company release information to identify an account holder whose tweets have been critical of President Trump.

The lawsuit threatened to become a major battle between Silicon Valley and Washington over free speech. But it was over almost before it began. The social networking site filed a lawsuit Thursday to protest the order, saying that it violated the user's First Amendment right to free expression. But Twitter dropped its suit Friday, saying in a court filing that because “the summons has now been withdrawn, Twitter voluntary dismisses without prejudice all claims.”

The DHS did not immediately respond to a request for comment.

Twitter filed the suit to protect the identity of a user who runs the @ALT_uscis feed, an account that purports to tweet the thoughts of a federal worker from U.S. Citizenship and Immigration Services. The two-month-old account is often critical of the Trump administration's immigration policies, particularly its plans to build a wall along the border with Mexico and its immigration travel ban.

Legal experts said Twitter would have had a strong case had it gone to court because the government had not provided compelling information on why it was necessary to identify the critic.

The government, to enforce its subpoena, would have had to demonstrate that whoever is behind the Twitter account was likely to be violating some law. There also were questions about whether the type of subpoena used, which is typically for investigating violations of trade rules, was appropriate for the type of case the DHS was probing, experts said.

Courts have traditionally given a high degree of protection to political speech, including the right to speak anonymously or with a pseudonym. That includes, in many circumstances, government employees who are critical of the agencies for which they work.

“This is just, as best as I can tell, the government trying to figure out who is expressing criticisms, and that is chilling,” said Marc Rotenberg, executive director of the Electronic Privacy Information Center.

If the goal was to quiet the dissent, it seems to have failed. The number of followers for the Twitter account grew from “over 32,000” to more than 150,000 in less than 24 hours.

Twitter filed a federal lawsuit on April 6 to block an order by the U.S. government demanding that it reveal who is behind an account opposed to President Trump's tough immigration policies. (Reuters)

Sen. Ron Wyden (D-Ore.) on Thursday called the government’s attempt to unmask the identity of the Twitter user a “witch hunt.” On Friday Wyden sent a letter to DHS's Customs and Border Protection agency, which demanded the information, asking them to investigate "why and how" the order came about.

"Not only was the summons blatantly inconsistent with the cited investigatory authority, section 509 of the Tariff Act of 1930, but it appeared to be a disturbing threat to free speech and whistleblower protections," Wyden's letter said.

A lawyer at the American Civil Liberties Union, which represented the user, said in a statement Friday that the speed with which the government withdrew the request shows how problematic its demand was.

“Speaking anonymously about issues of the day is a longstanding American tradition, dating back to when the framers of the Constitution wrote under pseudonyms,” said Esha Bhandari, one of the lawyers. “The anonymity that the First Amendment guarantees is often most essential when people criticize the government, and this free speech right is as important today as ever.”

Twitter has fought battles with the government before over user privacy. In 2012, the social network appealed an order from the state of New York to reveal personal user data from the account of Occupy Wall Street protester Malcolm Harris. It lost that appeal. The company also sued the Justice Department in 2014 for the right to make federal information requests for user data public.

Twitter’s actions this week highlight how much responsibility social media platforms hold in today’s debates about the right to free expression in the modern world, experts said. While social media networks may give a voice to millions of individuals, it is the companies' opinions, clout and resources that actually speak volumes.

“People love to speak about a global town square, but it’s hosted on company servers and not government servers. That means that the rights and terms and conditions that are granted are very much determined by a small group of people,” said Alex Howard, deputy director at the Sunlight Foundation, a nonprofit that focuses on technology and open government. “The choices they make to stand up for their users set important precedents for other companies now and into the future.”

The person behind @ALT_uscis did not respond to a request for comment sent over Twitter. But the user did thank Twitter and the ACLU.

“We are taking a break! The past few days have been extremely difficult and full of anxiety,” read another message from the account. “Thank you again America!”