The account in question is purportedly run by one or more current employees of the US Citizenship and Immigration Services (USCIS), a unit within Homeland Security.
Trump has vowed to build a wall along the US border with Mexico and has promised to deport millions of illegal immigrants.
Following Trump's inauguration in January, anonymous Twitter feeds voicing concerns at more than a dozen USA government agencies appeared to challenge the president's views on climate change and other issues. Twitter had no additional comment beyond the lawsuit.
Twitter, which counts Trump among its active users, has a record of litigating in favour of user privacy.
DHS Press Secretary Jenny Burke told NBC News: "As a matter of policy, we do not comment on pending litigation".
A recent message cites the text of the First Amendment.
They note that @alt_uscis was expressing dissent, criticizing immigration policies and disagreeing with other Trump administration policies.
Russian banker convicted in U.S. spy ring deported to Moscow
Carter Page told Buzzfeed that he had met with a Russian intelligence operative named Victor Podobnyy in New York City in 2013. In December, Donald Trump's son-in-law and close adviser met privately with the head of a Russian bank under USA sanctions.
Two CBP agents sent the summons to Twitter last month and said it was "required to turn over "a$3 ll records regarding the [T] witter account @ALT_USCIS to include, User names, account login, phone numbers, mailing addresses, and I.P. addresses".
The order said it was "in connection with an investigation or inquiry to ascertain the correctness of entries, to determine the liability for duties, taxes, fines, penalties, or forfeitures, and/or to ensure compliance with the laws or regulations".
The summons threatened to take Twitter to court if it failed to comply with the order.
"Twitter and other social media sites make promises to users about protecting anonymity".
Twitter filed suit on Thursday against the USA government, asking a court to back its refusal to hand over the identities of users claiming to be dissenting federal employees.
Twitter, like other social media companies, frequently receives requests from law enforcement agencies to remove content or for more information about specific accounts. In that case, Twitter was forced to hand over tweets from the protester to a judge who threatened the company with sanctions, and the protester pleaded guilty to disorderly conduct.
Twitter -owner of the president's favorite communications platform - is fighting the U.S.