BOSTON – A JetBlue pilot who threatened to “harm himself in spectacular fashion” surrendered a gun to authorities in Massachusetts after they confronted him just before he boarded a flight at Logan International Airport, law enforcement authorities said Friday.

The pilot was not charged with illegal possession of a firearm, and the gun was taken by federal authorities, suggesting he might be a member of the Federal Flight Deck Officer program.

The post-9/11 program screens, trains, arms and deputizes pilots as a last line of aircraft security. There are reportedly 10,000 pilots carrying handguns under the program.

The conflict occurred Thursday, and the pilot was immediately taken to Massachusetts General Hospital for evaluation. The airline refused to identify him and issued a statement saying he was removed from duty “for health-related reasons.”

JetBlue also said no passengers were harmed, nor was any flight in jeopardy. The airline did not respond to a request for information about the specific flight the pilot had been slated to work.

George Naccara, who oversees Logan’s security for the federal Transportation Security Administration, said the distraught pilot made the threat in an e-mail to a flight attendant who was a former girlfriend. Seven Massachusetts state troopers confronted him at a crew lounge about an hour before takeoff.

He had been slated to serve as first officer, meaning he would have been second in command to the captain.

“The person was so distraught that he was threatening to harm himself in spectacular fashion,” Naccara said in an interview with WBZ-TV. “Never did he threaten the aircraft or the passengers or anybody involved with the plane itself.”

Naccara added: “It was described in the e-mail it was probably going to happen during an overnight. So, my guess would have been someplace other than in the airport or an airplane.”

Massachusetts State Police spokesman David Procopio could not say whether the pilot threatened to misuse the gun itself.

Procopio told The Associated Press that three troopers, quickly backed up by four more, confronted the pilot after a federal air marshal relayed the concerns of the flight attendant.

“The subject was in possession of a firearm, which has been seized. The investigation is ongoing,” Procopio said.

Asked whether the pilot was a member of the Flight Deck Officer program, Procopio said: “He was not charged with firearm possession.” He also said federal authorities took possession of the gun.

The TSA refused to confirm whether the pilot was a member of the program, citing security concerns.

“We have an investigation ongoing, and when that is finished, we will release more details,” spokesman Nelson Minerly said.

The Flight Deck Officer program is run by the Federal Air Marshal Service, which itself puts armed agents on select flights.

The program was instituted after the Sept. 11, 2001, terrorist attacks in which hijackers armed with box cutters seized control of four airliner cockpits. They crashed planes into the World Trade Center, the Pentagon and a Pennsylvania field.

Under the program, flight crew members are deputized as federal law enforcement officers. They are allowed to use a gun to defend against a crime or potential hijacking.