A federal air marshal “flashed a gun in flight,” prompting police to remove him from the plane upon arrival at the Twin Cities airport and handcuff him on the tarmac along with a fellow marshal, authorities said Tuesday.

The apprehensions occurred Monday night after the nonstop United Airlines Flight 3531 from Newark, N.J., landed at the Minneapolis-St. Paul International Airport, according to the federal Transportation Safety Administration (TSA).

The marshal was “on official business onboard a flight [and] was mistaken for a passenger by a flight attendant,” a TSA statement read. “Protocols for notification of law enforcement presence aboard an aircraft are in place to avoid incidents like this. TSA is working with the airline to determine the specific circumstances in this case.”

However, communication between the cockpit and the MSP control tower that was captured by the authoritative website Liveatc.net revealed that it was confirmed onboard fairly quickly that both men were federal air marshals, and one of them “actually showed our flight attendant his gun,” one of the pilots reported soon after landing.

“That is completely against SOP [standard operating procedure] for them to show their firearm,” the pilot added. “So that’s the reason we declared an emergency.”

Airport spokesman Patrick Hogan defended the airport officers’ actions and spelled out in detail why they had no choice but to detain the men and take them to the airport’s police station for questioning by the FBI.

“We know we have a call from the flight crew indicating a passenger flashed a gun in flight,” he said. “We contact the FBI (in-flight incidents are their jurisdiction) and make preparations to board the flight in a remote area when it lands. ... We then take the individuals to the police operations center for questioning by the investigating agency, the FBI, whose job it is to get to the bottom of who the individuals are and discern the facts behind the situation that led to the call for police help.

“Our first priority is always to ensure everyone’s safety, and that involves first creating a separation between the public and suspicious objects or individuals and then determining whether or not the individual or object presents an actual threat. That is precisely what happened [Monday] night.”

Hogan said that it was up to federal and airline officials to explain why the flight attendant failed to realize the armed man she was a federal air marshal. Those officials have yet to address how the misidentification occurred.

FBI spokeswoman Cindy Burnham said the marshal mistaken for an armed civilian was assigned to be on that particular flight. A TSA spokesperson verified with the Star Tribune that the second person detained also was a federal air marshal.

The flight was operated by Indianapolis-based Republic Airline, which partners with United and other major carriers in commercial air service. Republic said in a statement late Tuesday morning, “We are aware of this incident and are working with investigators.”

Passenger Jennifer Berman told the Star Tribune that she and the others aboard were informed that the landing was being delayed briefly because “our gate was occupied, which was a total lie.”

Minutes later and while the aircraft was on the tarmac but not yet at the gate, Berman said, “police cars surround the plane and the pilot signaled the two flight attendants to prepare the doors for arrival — in the middle of runway.”

Berman said at least four police officers boarded and “quietly asked the two gentlemen” sitting across the aisle from each other in first class “to come with them. They went up and went down the stairs.”

She said the two, dressed in slacks and button-down shirts, were then handcuffed while on the tarmac.

A few more officers came aboard and questioned passengers who had been sitting near the two men, Berman said.