WASHINGTON -- As U.S. President Donald Trump's supporters massed outside the Capitol last week and sang the national anthem, a line of men wearing olive-drab helmets and body armour trudged purposefully up the marble stairs in a single-file line, each man holding the jacket collar of the one ahead.

The formation, known as "Ranger File," is standard operating procedure for a combat team that is "stacking up" to breach a building -- instantly recognizable to any U.S. soldier or Marine who served in Iraq and Afghanistan. It was a chilling sign that many at the vanguard of the mob that stormed the seat of American democracy either had military training or were trained by those who did.

An Associated Press review of public records, social media posts and videos shows at least 21 current or former members of the U.S. military or law enforcement have been identified as being at or near the Capitol riot, with more than a dozen others under investigation but not yet named. In many cases, those who stormed the Capitol appeared to employ tactics, body armour and technology such as two-way radio headsets that were similar to those of the very police they were confronting.

Experts in homegrown extremism have warned for years about efforts by far-right militants and white-supremacist groups to radicalize and recruit people with military and law enforcement training, and they say the Jan. 6 insurrection that left five people dead saw some of their worst fears realized.

"ISIS and al-Qaida would drool over having someone with the training and experience of a U.S. military officer," said Michael German, a former FBI agent and fellow with the Brennan Center for Justice at New York University. "These people have training and capabilities that far exceed what any foreign terrorist group can do. Foreign terrorist groups don't have any members who have badges."

Among the most prominent to emerge is a retired Air Force lieutenant colonel and decorated combat veteran from Texas who was arrested after he was photographed wearing a helmet and body armour on the floor of the Senate, holding a pair of zip-tie handcuffs.

Another Air Force veteran from San Diego was shot and killed by a Capitol Police officer as she tried to leap through a barricade near the House chamber. A retired Navy SEAL, among the most elite special warfare operators in the military, posted a Facebook video about travelling from his Ohio home to the rally and seemingly approving of the invasion of "our building, our house."

Two police officers from a small Virginia town, both of them former infantrymen, were arrested by the FBI after posting a selfie of themselves inside the Capitol, one flashing his middle finger at the camera.

Also under scrutiny is an active-duty psychological warfare captain from North Carolina who organized three busloads of people who headed to Washington for the "Save America" rally in support the president's false claim that the November election was stolen from him.

While the Pentagon declined to provide an estimate for how many other active-duty military personnel are under investigation, the military's top leaders were concerned enough ahead of President-elect Joe Biden's inauguration that they issued a highly unusual warning to all service members this week that the right to free speech gives no one the right to commit violence.

The chief of the U.S. Capitol Police was forced to resign following the breach and several officers have been suspended pending the outcome of investigations into their conduct, including one who posed for a selfie with a rioter and another who was seen wearing one of Trump's red "Make America Great Again" caps.

The AP's review of hundreds of videos and photos from the insurrectionist riot shows scores of people mixed in the crowd who were wearing military-style gear, including helmets, body armour, rucksacks and two-way radios. Dozens carried canisters of bear spray, baseball bats, hockey sticks and pro-Trump flags attached to stout poles later used to bash police officers.

A close examination of the group marching up the steps to help breach the Capitol shows they wore military-style patches that read "MILITIA" and "OATHKEEPER." Others were wearing patches and insignias representing far-right militant groups, including the Proud Boys, the Three Percenters and various self-styled state militias.

The Oath Keepers, which claims to count thousands of current and former law enforcement officials and military veterans as members, have become fixtures at protests and counter-protests across the country, often heavily armed with semi-automatic carbines and tactical shotguns.

Stewart Rhodes, an Army veteran who founded the Oath Keepers in 2009 as a reaction to the presidency of Barack Obama, had been saying for weeks before the Capitol riot that his group was preparing for a civil war and was "armed, prepared to go in if the president calls us up."

Adam Newbold, the retired Navy SEAL from Lisbon, Ohio, whose more than two-decade military career includes multiple combat awards for valour, said in a Jan. 5 Facebook video, "We are just very prepared, very capable and very skilled patriots ready for a fight."

He later posted a since-deleted follow-up video after the riot saying he was "proud" of the assault.

Newbold, 45, did not respond to multiple messages from the AP but in an interview with the Task & Purpose website he denied ever going inside the Capitol. He added that because of the fallout from the videos he has resigned from a program that helps prepare potential SEAL applicants.

Retired Air Force Lt. Col. Larry Rendall Brock Jr. of Texas was released to home confinement Thursday after a prosecutor alleged the former fighter pilot had zip-tie handcuffs on the Senate floor because he planned to take hostages.

"He means to kidnap, restrain, perhaps try, perhaps execute members of the U.S. government," Assistant U.S. Attorney Jay Weimer said. "His prior experience and training make him all the more dangerous."

Army commanders at Fort Bragg in North Carolina are investigating the possible involvement of Capt. Emily Rainey, the 30-year-old psychological operations officer and Afghanistan war veteran who told the AP she travelled with 100 others to Washington to "stand against election fraud." She insisted she acted within Army regulations and that no one in her group entered the Capitol or broke the law.

"I was a private citizen and doing everything right and within my rights," Rainey said.

More than 110 people have been arrested on charges related to the Capitol riot so far, ranging from curfew violations to serious federal felonies related to theft and weapons possession.

Brian Harrell, who served as the assistant secretary for infrastructure protection at the Department of Homeland Security until last year, said it is "obviously problematic" when "extremist bad actors" have military and law enforcement backgrounds.

"Many have specialized training, some have seen combat, and nearly all have been fed disinformation and propaganda from illegitimate sources," Harrell said. "They are fueled by conspiracy theories, feel as if something is being stolen from them, and they are not interested in debate. This is a powder keg cocktail waiting to blow."

The FBI is warning of the potential for more bloodshed. In an internal bulletin issued Sunday, the bureau warned of plans for armed protests at all 50 state capitals and in Washington, D.C., in the coming weeks.

Meanwhile, police departments in such major cities as New York, Los Angeles, Las Vegas, Houston and Philadelphia announced they were investigating whether members of their agencies participated in the Capitol riot. The Philadelphia area's transit authority is also investigating whether seven of its police officers who attended Trump's rally in Washington broke any laws.

A Texas sheriff announced last week that he had reported one of his lieutenants to the FBI after she posted photos of herself on social media with a crowd outside the Capitol. Bexar County Sheriff Javier Salazar said Lt. Roxanne Mathai, a 46-year-old jailer, had the right to attend the rally but he's investigating whether she may have broken the law.

One of the posts Mathai shared was a photo that appeared to be taken Jan. 6 from among the mass of Trump supporters outside the Capitol, captioned: "Not gonna lie. ... aside from my kids, this was, indeed, the best day of my life. And it's not over yet."

A lawyer for Mathai, a mother and longtime San Antonio resident, said she attended the Trump rally but never entered the Capitol.

In Houston, Police Chief Art Acevedo said an 18-year veteran of the department suspected of joining the mob that breached the Capitol resigned before a disciplinary hearing that was set for Friday.

"There is no excuse for criminal activity, especially from a police officer," Acevedo said. "I can't tell you the anger I feel at the thought of a police officer, and other police officers, thinking they get to storm the Capitol."

Bleiberg reported from Dallas and LaPorta from in Delray Beach, Florida. Robert Burns and Mike Balsamo in Washington; Jim Mustian, Michael R. Sisak and Thalia Beaty in New York; Michael Kunzelman in College Park, Maryland; Juan A. Lozano in Houston; Claudia Lauer in Philadelphia; Martha Bellisle in Seattle; and Stefanie Dazio in Los Angeles contributed.