A JetBlue pilot's backpack containing a handgun was picked up by an unsuspecting passenger and the bag was brought aboard a flight at John F. Kennedy Airport Thursday, according to officials with knowledge of the incident.

The pilot, Michael Connery Jr., 49, of Orlando, Fla., told officials he had put down his bag containing a HK .40-caliber gun, which he is licensed and authorized to carry on flights, and three clips with 37 rounds of ammunition along with his other bags. He was chatting with a Delta pilot at the counter...