A Massachusetts Air National Guardsman arrested over the leak of highly classified military documents has appeared in court in Boston.

Jack Teixeira, 21, was arrested by heavily armed FBI agents on Thursday following a week-long criminal investigation into the disclosure of highly sensitive government records.

It was an alarming breach that exposed to the world unvarnished secret assessments of the war in Ukraine, the capabilities and geopolitical interests of other nations and other top national security issues.

A federal magistrate judge ordered that Teixeira must remain in jail at least until a detention hearing set for next Wednesday.

Leaked Documents Investigation
Jack Teixeira, in T-shirt and shorts, was arrested in Massachusetts (WCVB-TV via AP)

Court records unsealed on Friday showed billing records of a social media platform and interviews with another user helped the FBI identify Teixeira, who faces charges under the Espionage Act of unauthorised removal and retention of classified and national defence information.

He appeared in court in brown jail clothes for a brief hearing before US Magistrate Judge David Hennesy.

Investigators believe Teixeira was the leader of a private chat group on Discord, a social media platform popular with people playing online games.

Billing records the FBI obtained from Discord, which said it was cooperating with the bureau, helped lead investigators to Teixeira, according to an FBI affidavit.

According to the document, the FBI interviewed someone familiar with Teixeira’s online posts on Monday.

That person, who is not identified in the affidavit, told the FBI that a user name linked to Teixeira began posting what appeared to be classified information roughly in December.

Leaked Documents Investigation
A federal police vehicle is parked outside court in Boston (Mark Pratt/AP)

The affidavit suggests Teixeira switched from typing out documents in his possession to taking them home and photographing them because he “had become concerned that he may be discovered making the transcriptions of text in the workplace”.

That is different from what posters have told the Associated Press and other media outlets, saying the user they would call “the OG” started posting images of documents because he was annoyed other users were not taking him seriously.

The affidavit also alleges Teixeira was detected on April 6 – the day The New York Times first published a story about the release of documents – searching for the word “leak” in a classified system.

The FBI says that was reason to believe Teixeira was trying to find information about the investigation into who was responsible for the leaks.

Leaked Documents Investigation
Jack Teixeira’s family members leave after the court hearing (John Tlumacki/The Boston Globe via AP)

The Biden administration has scrambled to contain the potential diplomatic and military fallout from the leaks since they were first reported, moving to reassure allies and assess the scope of damage.

The classified documents — which have not been individually authenticated in public by US officials — range from briefing slides mapping out Ukrainian military positions to assessments of international support for Ukraine and other sensitive topics, including under what circumstances Russian president Vladimir Putin might use nuclear weapons.

In previous Associated Press stories, the leaker was identified as “the OG” by a member of the online chat group.

Known as Thug Shaker Central, the group drew roughly two dozen enthusiasts who talked about their favourite types of guns and also shared memes and jokes. The group also held a running discussion on wars that included talk of Russia’s invasion of Ukraine.

Defence Secretary Lloyd Austin, in a statement issued after the arrest, said the Pentagon would conduct a review of its “intelligence access, accountability and control procedures” to prevent such a leak from happening again.