Social media network Twitter has filed a lawsuit against the Trump administration defending free speech.

The US government ordered Twitter to reveal the identity of an account criticising Trump’s immigration policies. The account, @ALT_uscia, is claimed to be run by at least one employee of the Customs and Border Patrol immigration service.

The government agency demanded that the social network unmasks the user, and Twitter has refused to do so. In retaliation, the company, run by chief executive Jack Dorsey, instead posted a 25-page legal filing which pointed out how accounts on the network are using free speech to hold the administration to account.

As well as @ALT_uscia, there are other “rogue” government accounts that exist to fact-check statements made by the Trump administration and detail what is going on behind the scenes. For instance, the account @RoguePOTUSStaff describes itself as “the unofficial resistance team inside the White House.

The filing described these account as:

“a new and innovative class of American speakers … who provide views and commentary that is often vigorously opposed, resistant or ‘alternative’ to the official actions and policies of the new administration.”

It appears Twitter has jumped on this opportunity to prove itself as a defender of free speech when it has been often criticised for this in the past. For the past few years, the social network has been accused of not doing enough to prevent online abuse on the platform. Last year, actress Leslie Jones who starred in the all-female reboot of Ghostbusters was hounded off the platform by trolls. She condemned the racism she was subjected to and Twitter’s lack of action against it.

However, this year it has been making moves to prevent this type of action online. It introduced new measures that prevent people who had been suspended from the platform from creating new accounts, as well as a safe search feature that can hide tweets with potentially sensitive content.

Writing in a blog post, Twitter’s vice president of engineering, Ed Ho, said:

“We stand for freedom of expression and people being able to see all sides of any topic. That’s put in jeopardy when abuse and harassment stifle and silence those voices. We won’t tolerate it and we’re launching new efforts to stop it.”

Investors haven’t been happy with the platform’s stance on trolls. When Twitter posted its fourth quarter results this year, its shares dropped 10 percent after missing Wall Street expectations. Nevertheless, standing up to the Trump administration has given the platform some good press, with even the American Civil Liberties Union (ACLU) joining forces with Twitter to prevent the unmasking of the account.