A JetBlue flight bound for Las Vegas was diverted to Texas following what federal authorities described as "erratic behaviour" by the captain, who passengers said had to be restrained after he pounded on the locked cockpit door.
The captain went to a toilet just outside the cockpit, and when he emerged began shouting "Iraq, al-Qaeda, terrorism, we're all going down!" according to the Amarillo Globe-News newspaper.
"It was a little scary. He was pretty freaked out," passenger Heidi Karg told a US network.
"When they were trying to calm him down... they had to restrain him and a bunch of male passengers ran to the front of the plane to subdue him."
The FBI is investigating the incident on Flight 191 from New York, which had 135 passengers on board, when the pilot-in-command decided to redirect the plane to Amarillo, Texas.
JetBlue said in a statement the flight was diverted due to a "medical situation" involving the captain, but made no mention of any commotion on board.
Passengers who were on the plane described a chaotic mid-flight scene in which the man, apparently locked out of the cockpit, began banging on the door and demanding to be let inside.
"People behind me, a bunch of big guys, started going up there and trying to help, and we found out that the guy banging was actually the pilot, and he was trying to get into the cockpit because the other co-pilot had locked him out," passenger Grant Heppes said.
"Everybody seemed pretty nervous," he added. "Nobody was sure what was going on. Everybody seemed very concerned."
Karg said the captain had been pounding on the door saying: "I need the code. Give me the code."
Another woman on the plane said local law enforcement met passengers at the gate and interviewed them.
'Onboard medical emergency'
The plane, which took off from John F Kennedy International Airport in New York, had been scheduled to land at McCarran International Airport in Las Vegas.
JetBlue said that following a medical situation with the captain, another captain who was travelling off-duty entered the
flight deck prior to the landing and "took over the duties of the ill crew member once on the ground".
The crew member was removed from the aircraft and taken to a local medical facility. The airline brought in another aircraft and crew to take the passengers to Las Vegas, JetBlue said.
The Federal Aviation Administration cited an "onboard medical emergency" as the reason for the diversion, and said
preliminary information showed the co-pilot became concerned that the captain had "exhibited erratic behavior during the flight."
"The captain had exited the cockpit during the flight, after which the co-pilot locked the door," the statement said.
"When the captain attempted to enter the locked cockpit, he was subdued by passengers.
"After the flight landed safely, local law enforcement secured the pilot without incident and he was transported by ambulance for medical evaluation."
An Amarillo police spokeswoman declined to comment on the incident, but said her department was assisting the FBI.
Two weeks ago, a flight attendant started ranting about a possible crash over the public address system of an American Airlines plane.
She, too, was subdued by passengers and crew as the plane returned to the gate at Dallas-Fort Worth International Airport.