Tayyab Subhani, 30, and Mohammed Safdar, 42, deny charges of endangering a passenger aircraft.
The court heard some passengers had reported seeing the men, returning from Safdar's mother's funeral with his daughter and niece, behaving in a "rude and aggressive" manner before the flight took off.
When cabin crew made an announcement asking for a medical professional to assist an elderly passenger who had fallen ill, Safdar offered his services.
The crew established he had no medical credentials and turned him away, resulting in a confrontation, the court heard.
Safdar, encouraged by Subhani, then made threats to kill crew and passengers, resulting in "fear and panic", Mr O'Neill said.
The alleged threats, made in Urdu, included the words: "No more crew, no more passengers, finish everything."
Safdar is also alleged to have made stabbing hand gestures.
The pilot, who described the incident as the most serious of his career, contacted UK air traffic control and was instructed to begin emergency procedures.
The trial is expected to last five weeks.
More top news
Politicians and campaigners in Cambridge are calling on the Chancellor to lend his support to the city's underground scheme in the Budget.
Today is the 25th anniversary of the murder of schoolgirl Natalie Pearman in Norwich. The 16-year-old was found dead in a layby.
Outbreaks of rain at first today, turning brighter and drier into the afternoon. Breezy but milder. Highs of 13 deg C (55 deg F).