Twitter is often criticized—and rightfully so—for some of the decisions it has made in the past, including the fact that it moved too slowly to try and stop abuse of the service by trolls and bots.
But there is one thing the company routinely does right, and that is to fight back against government attempts to force it to reveal user information.
It did so again on Thursday by filing a lawsuit against the Department of Homeland Security in San Francisco. In the suit, Twitter has asked a judge to block the government’s order to divulge the personal details of the user behind a so-called “rogue” account, which claims to be run by employees of the Citizenship and Immigration Services department.
According to the company’s filing, the @ALT_uscis Twitter account “has often criticized immigration policies” introduced by Trump, including the travel ban imposed on a number of Muslim countries. The account, which was created right after the first Executive Order that introduced the ban, is one of a number of accounts that purport to be run by either current or former government employees.
“Defendants may not compel Twitter to disclose information regarding the real identities of these users without first demonstrating that some criminal or civil offense has been committed,” Twitter argues in its complaint. “Defendants have not come close to making any of these showings.”
This is not the first time Twitter has used the courts to fight such demands by the U.S. government. One of the first was in 2011, when the Justice Department ordered it to produce information about several of the people associated with the WikiLeaks account, including founder Julian Assange, hacker activist Jacob Appelbaum, and Icelandic MP Birgitta Jonsdottir.
As it has in the current case, Twitter rejected the order and also defied the government’s demand that it not inform the individuals in question about the agency’s request for information.
Ultimately, Twitter lost that case, which was supported by the American Civil Liberties Union and the Electronic Frontier Foundation. But it at least tried to resist the government’s demands, and it tried to force the incident out into the public eye as much as possible. Many other tech companies—including Facebook—comply with such requests but say very little about them.
Get Data Sheet, Fortune’s technology newsletter.
Twitter fought a government order in 2012 that tried to get it to reveal information about an account associated with the Occupy Wall Street protests. And it has also fought in court to block demands by other governments, including those from the Turkish authorities, which have tried to force it to shut down accounts critical of those in power.
It appears from the evidence introduced by Twitter in the current case that the government has been trying to identify the users behind the rogue account since early March, when the Customs and Border Protection agency sent the company a court order demanding the personal information of whoever created it. The order also forbid Twitter from informing those users of the government’s request.
Instead of complying, however, Twitter told the users behind the @ALT_uscis account about the agency’s demands, and filed suit to try and have the order struck down.
In its legal argument, the company makes the case that the CBP order goes beyond the scope of what is normally permitted by subpoenas of that kind, and it also argues that submitting to the agency’s demand would have a chilling effect on the users’ freedom of speech and therefore is in contravention of the First Amendment’s protections for such speech.
“The CBP Summons is unlawful and unenforceable because it violates the First Amendment rights of both Twitter and its users by seeking to unmask the identity of one or more anonymous Twitter users voicing criticism of the government on matters of public concern,” the filing states.
The company’s submission to the court goes on to point out that a “time-honored tradition of pseudonymous free speech on matters of public moment runs deep in the political life of America,” and that these First Amendment rights are “at their zenith when, as here, the speech at issue touches on matters of public political life.” The Supreme Court has written about the necessity for anonymity to allow for criticism of the government, the filing says.
Whether Twitter is ultimately successful or not in its latest attempt to resist the attacks on free speech, it deserves a lot of credit for at least trying to do so. That’s more than many companies do.